Skip to content

Commit

Permalink
Merge pull request #1621 from ebkr/more-file-locks
Browse files Browse the repository at this point in the history
Lock both source and destination files when copying or renaming files
  • Loading branch information
anttimaki authored Feb 17, 2025
2 parents 83f49ca + 1c6db46 commit eb4dd72
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/providers/generic/file/NodeFs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ export default class NodeFs extends FsProvider {

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

async copyFile(from: string, to: string): Promise<void> {
return new Promise((resolve, reject) => {
NodeFs.lock.acquire(from, async () => {
NodeFs.lock.acquire([from, to], async () => {
try {
await fs.promises.copyFile(from, to);
resolve();
Expand Down

0 comments on commit eb4dd72

Please sign in to comment.