mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-11-25 16:37:32 +00:00
fix(media-use): keep a failed write's error when replaceFile can't remove its temp file
The preferences store now writes through replaceFile. Its old write made temp cleanup best-effort, so a cleanup error never hid the write error, and the store's tests guard that. replaceFile now does the same.
This commit is contained in:
@@ -118,8 +118,12 @@ export function replaceFile(path, content) {
|
||||
writeFileSync(temp, content, { flag: "wx" });
|
||||
renameRidingWindowsHolds(temp, path);
|
||||
} catch (error) {
|
||||
// EEXIST: the random name belongs to another writer, so it is left alone.
|
||||
if (error?.code !== "EEXIST") rmSync(temp, { force: true });
|
||||
// EEXIST: the random name belongs to another writer, so it is left alone. A failed cleanup must not hide `error`.
|
||||
if (error?.code !== "EEXIST") {
|
||||
try {
|
||||
rmSync(temp, { force: true });
|
||||
} catch {}
|
||||
}
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
"files": 13
|
||||
},
|
||||
"media-use": {
|
||||
"hash": "78085d6f3c4afd96",
|
||||
"hash": "9c3e2f0be3c30add",
|
||||
"files": 131
|
||||
},
|
||||
"remotion-to-hyperframes": {
|
||||
|
||||
@@ -118,8 +118,12 @@ export function replaceFile(path, content) {
|
||||
writeFileSync(temp, content, { flag: "wx" });
|
||||
renameRidingWindowsHolds(temp, path);
|
||||
} catch (error) {
|
||||
// EEXIST: the random name belongs to another writer, so it is left alone.
|
||||
if (error?.code !== "EEXIST") rmSync(temp, { force: true });
|
||||
// EEXIST: the random name belongs to another writer, so it is left alone. A failed cleanup must not hide `error`.
|
||||
if (error?.code !== "EEXIST") {
|
||||
try {
|
||||
rmSync(temp, { force: true });
|
||||
} catch {}
|
||||
}
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user