mirror of
https://github.com/usebruno/bruno.git
synced 2025-01-03 04:29:09 +01:00
Prevent data-loss if we are unable to write the new file
This commit is contained in:
parent
fd22ff8962
commit
c30b4ff3c6
@ -392,8 +392,9 @@ const registerRendererEventHandlers = (mainWindow, watcher, lastOpenedCollection
|
|||||||
moveRequestUid(oldPath, newPath);
|
moveRequestUid(oldPath, newPath);
|
||||||
|
|
||||||
const content = jsonToBru(jsonData);
|
const content = jsonToBru(jsonData);
|
||||||
await fs.promises.unlink(oldPath);
|
// we must write the new file first to avoid data loss if an exception occurs during write
|
||||||
await writeFile(newPath, content);
|
await writeFile(newPath, content);
|
||||||
|
await fs.promises.unlink(oldPath);
|
||||||
|
|
||||||
return newPath;
|
return newPath;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
Loading…
Reference in New Issue
Block a user