Fix TIC replace bug

This commit is contained in:
Bryan Ashby 2020-11-21 14:56:03 -07:00
parent 939c07f466
commit 8aa878a3ee
No known key found for this signature in database
GPG Key ID: B49EB437951D2542
1 changed files with 8 additions and 0 deletions

View File

@ -1879,6 +1879,8 @@ function FTNMessageScanTossModule() {
localInfo.fileEntry.fileName = paths.basename(finalPath);
}
localInfo.newPath = dst;
localInfo.fileEntry.persist(isUpdate, err => {
return callback(err, localInfo);
});
@ -1893,6 +1895,12 @@ function FTNMessageScanTossModule() {
const oldStorageDir = getAreaStorageDirectoryByTag(localInfo.oldStorageTag);
const oldPath = paths.join(oldStorageDir, localInfo.oldFileName);
// if we updated a file in place, don't delete it!
if (localInfo.newPath === oldPath) {
Log.trace({path : oldPath}, 'TIC file replaced in place. Nothing to remove.');
return callback(null, localInfo);
}
fs.unlink(oldPath, err => {
if(err) {
Log.warn( { error : err.message, oldPath : oldPath }, 'Failed removing old physical file during TIC replacement');