protected static function is_file_removable($contenthash) {
        global $DB;

        if ($contenthash === file_storage::hash_from_string('')) {
            // No need to delete files without content.
            return false;
        }

        // Note: This section is critical - in theory file could be reused at the same time, if this
        // happens we can still recover the file from trash.
        // Technically this is the responsibility of the file_storage API, but as this method is public, we go belt-and-braces.
        if ($DB->record_exists('files', array('contenthash' => $contenthash))) {
            // File content is still used.
            return false;
        }

        return true;
    }