diff --git a/lib/filestorage/file_storage.php b/lib/filestorage/file_storage.php index 0fb99228193..b5d6fdd72fb 100644 --- a/lib/filestorage/file_storage.php +++ b/lib/filestorage/file_storage.php @@ -2004,9 +2004,9 @@ class file_storage { ignore_user_abort($prev); throw new file_exception('storedfilecannotcreatefile'); } - if (filesize($hashfile.'.tmp') !== $filesize) { - // This should not happen. - unlink($hashfile.'.tmp'); + if (sha1_file($hashfile.'.tmp') !== $contenthash) { + // Highly unlikely edge case, but this can happen on an NFS volume with no space remaining. + @unlink($hashfile.'.tmp'); ignore_user_abort($prev); throw new file_exception('storedfilecannotcreatefile'); }