Skip to content

Commit 47d4703

Browse files
author
dustinhuynh
committed
Add fallback check for directories created between calls
1 parent 2c52ac4 commit 47d4703

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

classes/local/store/object_file_system.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -336,15 +336,11 @@ public function copy_object_from_external_to_local_by_hash($contenthash, $object
336336

337337
if ($initiallocation === OBJECT_LOCATION_EXTERNAL) {
338338

339-
$localpath = $this->get_local_path_from_hash($contenthash);
340339
$localdirpath = $this->get_fulldir_from_hash($contenthash);
341340

342341
// Folder may not exist yet if pulling a file that came from another environment.
343-
if (!is_dir($localdirpath)) {
344-
if (!mkdir($localdirpath, $this->dirpermissions, true)) {
345-
// Permission trouble.
346-
throw new file_exception('storedfilecannotcreatefiledirs');
347-
}
342+
if (!is_dir($localdirpath) && !mkdir($localdirpath, $this->dirpermissions, true) && !is_dir($localdirpath)) {
343+
throw new \file_exception('storedfilecannotcreatefiledirs');
348344
}
349345

350346
$success = $this->copy_from_external_to_local($contenthash);

0 commit comments

Comments
 (0)