From 2ee668ec56cc5b830bc03b59656613cb943e8027 Mon Sep 17 00:00:00 2001 From: Tony Butler Date: Mon, 8 Aug 2016 15:29:14 +0100 Subject: [PATCH] MDL-55513 core_filestorage: Touch and test size instead of file_exists() file_exists() can return false when file exists (in certain scenarios) --- lib/filestorage/file_storage.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/filestorage/file_storage.php b/lib/filestorage/file_storage.php index 0480bf794ba..38a20a11026 100644 --- a/lib/filestorage/file_storage.php +++ b/lib/filestorage/file_storage.php @@ -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;