diff --git a/classes/local/store/object_file_system.php b/classes/local/store/object_file_system.php index de30f1d2..de53f1a4 100644 --- a/classes/local/store/object_file_system.php +++ b/classes/local/store/object_file_system.php @@ -246,14 +246,14 @@ public function is_file_readable_externally_by_storedfile(stored_file $file) { * @return bool */ public function is_file_readable_externally_by_hash($contenthash) { - if ($contenthash === sha1('')) { - // Files with empty size are either directories or empty. + $path = $this->get_external_path_from_hash($contenthash, false); + + if ($contenthash === sha1('') && is_dir($path)) { + // Explicitly check if it is a directory, handle empty files as normal. // We handle these virtually. return true; } - $path = $this->get_external_path_from_hash($contenthash, false); - // Note - it is not possible to perform a content recovery safely from a hash alone. return is_readable($path); } diff --git a/settings.php b/settings.php index aef3c571..b337de57 100644 --- a/settings.php +++ b/settings.php @@ -110,6 +110,9 @@ new lang_string('settings:tokenexpirywarnperiod', 'tool_objectfs'), '', 60 * DAYSECS, DAYSECS)); + $settings->add(new admin_setting_configcheckbox('tool_objectfs/preferexternal', + new lang_string('settings:preferexternal', 'tool_objectfs'), '', '')); + $settings->add(new admin_setting_heading('tool_objectfs/filetransfersettings', new lang_string('settings:filetransferheader', 'tool_objectfs'), '')); @@ -247,10 +250,4 @@ } } } - - $settings->add(new admin_setting_heading('tool_objectfs/testsettings', - new lang_string('settings:testingheader', 'tool_objectfs'), '')); - - $settings->add(new admin_setting_configcheckbox('tool_objectfs/preferexternal', - new lang_string('settings:preferexternal', 'tool_objectfs'), '', '')); }