MCPcopy Create free account
hub / github.com/error311/FileRise / writeAtomic

Method writeAtomic

src/FileRise/Domain/UserModel.php:63–81  ·  view source on GitHub ↗
(string $path, string $data)

Source from the content-addressed store, hash-verified

61 }
62
63 private static function writeAtomic(string $path, string $data): bool
64 {
65 $dir = dirname($path);
66 $tmp = $path . '.tmp.' . bin2hex(random_bytes(6));
67 if (!is_dir($dir)) {
68 return false;
69 }
70 if (file_put_contents($tmp, $data, LOCK_EX) === false) {
71 if (is_file($tmp)) {
72 @unlink($tmp);
73 }
74 return false;
75 }
76 if (!@rename($tmp, $path)) {
77 @unlink($tmp);
78 return false;
79 }
80 return true;
81 }
82
83 private static function mergePermissionsMostRestrictive($base, $incoming): array
84 {

Callers 4

markSetupCompleteMethod · 0.95
removeUserMethod · 0.95
updateUserPermissionsMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected