mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-16 07:24:53 +09:00
Rename safeOutputFile to atomicOverwriteFile (#1167)
"safe" suggested the data being written survives a crash, it only guarantees the old file is either kept or fully replaced. The new name says what it does. No alias, plugin API breaks are allowed in minor versions and the 2.1 migration guide lists the rename. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: Cooldude2606 <25043174+Cooldude2606@users.noreply.github.com>
This commit is contained in:
19 files changed
+55
-49
No files matched your search
@@ -63,7 +63,7 @@ async function saveDatabase(
|
||||
let file = path.resolve(controllerConfig.get("controller.database_directory"), "player_sync.json");
|
||||
logger.verbose(`writing ${file}`);
|
||||
let content = JSON.stringify([...playerDatastore, ...tombstones]);
|
||||
await lib.safeOutputFile(file, content);
|
||||
await lib.atomicOverwriteFile(file, content);
|
||||
}
|
||||
|
||||
export default async function(context: ControllerPluginContext) {
|
||||
|
||||
@@ -49,7 +49,7 @@ async function saveTechnologies(
|
||||
) {
|
||||
let filePath = path.join(controllerConfig.get("controller.database_directory"), "technologies.json");
|
||||
logger.verbose(`writing ${filePath}`);
|
||||
await lib.safeOutputFile(filePath, JSON.stringify([...technologies.entries()], null, "\t"));
|
||||
await lib.atomicOverwriteFile(filePath, JSON.stringify([...technologies.entries()], null, "\t"));
|
||||
}
|
||||
|
||||
const MAX_QUEUE = 7;
|
||||
@@ -71,7 +71,7 @@ async function loadQueue(controllerConfig: lib.ControllerConfig, logger: lib.Log
|
||||
async function saveQueue(controllerConfig: lib.ControllerConfig, queue: string[], logger: lib.Logger) {
|
||||
let filePath = path.join(controllerConfig.get("controller.database_directory"), "research_queue.json");
|
||||
logger.verbose(`writing ${filePath}`);
|
||||
await lib.safeOutputFile(filePath, JSON.stringify(queue, null, "\t"));
|
||||
await lib.atomicOverwriteFile(filePath, JSON.stringify(queue, null, "\t"));
|
||||
}
|
||||
|
||||
export default async function(context: ControllerPluginContext) {
|
||||
|
||||
@@ -64,7 +64,7 @@ async function saveDatabase(
|
||||
let file = path.resolve(controllerConfig.get("controller.database_directory"), "items.json");
|
||||
logger.verbose(`writing ${file}`);
|
||||
let content = JSON.stringify(items.serialize());
|
||||
await lib.safeOutputFile(file, content);
|
||||
await lib.atomicOverwriteFile(file, content);
|
||||
} else if (items) {
|
||||
logger.error(`Item database too large, not saving (${items.size})`);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user