Skip to content

Commit e9c8db3

Browse files
committed
Add lock on deleteResource.
1 parent fd3b2b1 commit e9c8db3

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

lib/ldp.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -452,11 +452,17 @@ class LDP {
452452
}
453453

454454
async deleteResource (path) {
455+
let releaseLock
455456
try {
456-
return promisify(fs.unlink)(path)
457+
releaseLock = await lock(path, { retries: 10 })
458+
return await promisify(fs.unlink)(path)
457459
} catch (err) {
458460
debug.container('DELETE -- unlink() error: ' + err)
459461
throw error(err, 'Failed to delete resource')
462+
} finally {
463+
if (releaseLock) {
464+
await releaseLock()
465+
}
460466
}
461467
}
462468

0 commit comments

Comments
 (0)