Merge pull request #121 from pierotofy/duplicatedir

Delete previous directory if already exists during task init
pull/123/head
Stephen Mather 2020-08-26 16:00:36 -04:00 zatwierdzone przez GitHub
commit a6347a1b9b
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
1 zmienionych plików z 10 dodań i 1 usunięć

Wyświetl plik

@ -259,7 +259,16 @@ module.exports = {
if (req.files && req.files.length > 0) {
fs.stat(destPath, (err, stat) => {
if (err && err.code === 'ENOENT') cb();
else cb(new Error(`Directory exists (should not have happened)`));
else{
// Directory already exists, this could happen
// if a previous attempt at upload failed and the user
// used set-uuid to specify the same UUID over the previous run
// Try to remove it
removeDirectory(destPath, err => {
if (err) cb(new Error(`Directory exists and we couldn't remove it.`));
else cb();
});
}
});
} else {
cb();