Patch for race condition with filesystem and process cleanup

This commit is contained in:
Thomas Hobson 2021-05-07 19:23:34 +12:00
parent 95421c9e15
commit 9590d5afbc
No known key found for this signature in database
GPG key ID: 9F1FD9D87950DB6F
2 changed files with 57 additions and 3 deletions

View file

@ -219,9 +219,14 @@ class Job {
for (const file of contents) {
const file_path = path.join(clean_path, file);
const stat = await fs.stat(file_path);
if(stat.uid == this.uid)
await fs.rm(file_path, { recursive: true, force: true });
try{
const stat = await fs.stat(file_path);
if(stat.uid == this.uid)
await fs.rm(file_path, { recursive: true, force: true });
}catch(e){
// File was somehow deleted in the time that we read the dir to when we checked the file
logger.warn(`Error removing file ${file_path}: ${e}`)
}
}
}