Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issues 633 & 634 -MOODLE_310_STABLE #637

Open
wants to merge 2 commits into
base: MOODLE_310_STABLE
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions classes/local/store/object_file_system.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
9 changes: 3 additions & 6 deletions settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'), ''));

Expand Down Expand Up @@ -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'), '', ''));
}
Loading