Browse Source

Only protect file if it was written

rugk 10 năm trước cách đây
mục cha
commit
54f1cb9d34
1 tập tin đã thay đổi với 1 bổ sung1 xóa
  1. 1 1
      lib/persistence.php

+ 1 - 1
lib/persistence.php

@@ -116,10 +116,10 @@ abstract class persistence
         self::_initialize();
         $file = self::$_path . DIRECTORY_SEPARATOR . $filename;
         $writtenBytes = @file_put_contents($file, $data, LOCK_EX);
-        chmod($file, 0640); // protect file access
         if ($writtenBytes === false || $writtenBytes < strlen($data)) {
             throw new Exception('unable to write to file ' . $file, 13);
         }
+        chmod($file, 0640); // protect file access
         return $file;
     }
 }