MDL-55513 core_filestorage: Touch and test size instead of file_exists()
authorTony Butler <tonyjbutler@gmail.com>
Mon, 8 Aug 2016 14:29:14 +0000 (15:29 +0100)
committerTony Butler <tonyjbutler@gmail.com>
Wed, 10 Aug 2016 08:35:23 +0000 (09:35 +0100)
file_exists() can return false when file exists (in certain scenarios)

lib/filestorage/file_storage.php

index 0480bf7..38a20a1 100644 (file)
@@ -386,7 +386,8 @@ class file_storage {
         chdir($tmp);
         $result = exec($cmd, $output);
         chdir($currentdir);
-        if (!file_exists($newtmpfile)) {
+        touch($newtmpfile);
+        if (filesize($newtmpfile) === 0) {
             remove_dir($tmp);
             // Cleanup.
             return false;