mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-15 07:24:52 +09:00
Fix safeOutputFile writing to wrong directory (#659)
When renaming a file over another file the operation is only atomic if both the source file and the target file is in the same directory. Fix safeOutputFile writing the temporary file to a different directory than the target file due to the path separator not being included when creating the temporary file path.
This commit is contained in:
1 parent
84958e3f9d
commit
6226a45d0b
1 file changed
+1
-1
@@ -142,7 +142,7 @@ export async function safeOutputFile(file: string, data: string | Buffer, option
|
||||
if (dir && !await fs.pathExists(dir)) {
|
||||
await fs.mkdirs(dir);
|
||||
}
|
||||
let temporary = `${dir}${name}.tmp${ext}`;
|
||||
let temporary = path.join(dir, `${name}.tmp${ext}`);
|
||||
let fd = await fs.open(temporary, "w");
|
||||
try {
|
||||
await fs.writeFile(fd, data, options);
|
||||
|
||||
Reference in new issue
Block a user