Skip to content

Commit 1c6db46

Browse files
committed
Lock both source and destination files when copying or renaming files
This seems to resolve a race condition issue where a disabled mod was imported as a part of a profile. Before the fix, renaming the file with ".old" extension when disabling the mod after copying it into profile caused an EBUSY error.
1 parent 669d972 commit 1c6db46

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

Diff for: src/providers/generic/file/NodeFs.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ export default class NodeFs extends FsProvider {
9393

9494
async rename(path: string, newPath: string): Promise<void> {
9595
return new Promise((resolve, reject) => {
96-
NodeFs.lock.acquire(path, async () => {
96+
NodeFs.lock.acquire([path, newPath], async () => {
9797
try {
9898
await fs.promises.rename(path, newPath);
9999
resolve();
@@ -110,7 +110,7 @@ export default class NodeFs extends FsProvider {
110110

111111
async copyFile(from: string, to: string): Promise<void> {
112112
return new Promise((resolve, reject) => {
113-
NodeFs.lock.acquire(from, async () => {
113+
NodeFs.lock.acquire([from, to], async () => {
114114
try {
115115
await fs.promises.copyFile(from, to);
116116
resolve();

0 commit comments

Comments
 (0)