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

Method writeSiteConfig

src/FileRise/Domain/AdminModel.php:379–400  ·  view source on GitHub ↗

Write USERS_DIR/siteConfig.json atomically (unencrypted). */

(array $publicSubset)

Source from the content-addressed store, hash-verified

377
378 /** Write USERS_DIR/siteConfig.json atomically (unencrypted). */
379 public static function writeSiteConfig(array $publicSubset): array
380 {
381 $dest = rtrim(USERS_DIR, '/\\') . DIRECTORY_SEPARATOR . 'siteConfig.json';
382 $tmp = $dest . '.tmp';
383
384 $json = json_encode($publicSubset, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
385 if ($json === false) {
386 return ["error" => "Failed to encode siteConfig.json"];
387 }
388
389 if (file_put_contents($tmp, $json, LOCK_EX) === false) {
390 return ["error" => "Failed to write temp siteConfig.json"];
391 }
392
393 if (!@rename($tmp, $dest)) {
394 @unlink($tmp);
395 return ["error" => "Failed to move siteConfig.json into place"];
396 }
397
398 @chmod($dest, 0664); // readable in bind mounts
399 return ["success" => true];
400 }
401
402 /**
403 * Updates the admin configuration file.

Callers 4

updateConfigMethod · 0.95
siteConfigMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected