Delete file if exists when copying to {error,processed}StorePath (watch folder)
This commit is contained in:
parent
fe241db5db
commit
c43be84507
1 changed files with 22 additions and 2 deletions
|
|
@ -107,12 +107,22 @@ public class WatchFolderChecker(ILogger<WatchFolderChecker> logger, IServiceProv
|
|||
await torrentService.UploadMagnet(magnetLink, torrent);
|
||||
}
|
||||
|
||||
var processedPath = Path.Combine(processedStorePath, fileInfo.Name);
|
||||
|
||||
if (!Directory.Exists(processedStorePath))
|
||||
{
|
||||
Directory.CreateDirectory(processedStorePath);
|
||||
}
|
||||
|
||||
var processedPath = Path.Combine(processedStorePath, fileInfo.Name);
|
||||
|
||||
if (File.Exists(processedPath))
|
||||
{
|
||||
File.Delete(processedPath);
|
||||
|
||||
logger.Log(LogLevel.Warning,
|
||||
"File {torrentFileName} replaced in {processedStorePath} - it already existed and new torrent with same filename was added",
|
||||
fileInfo.Name,
|
||||
processedStorePath);
|
||||
}
|
||||
|
||||
File.Move(torrentFile, processedPath);
|
||||
|
||||
|
|
@ -126,6 +136,16 @@ public class WatchFolderChecker(ILogger<WatchFolderChecker> logger, IServiceProv
|
|||
}
|
||||
|
||||
var processedPath = Path.Combine(errorStorePath, fileInfo.Name);
|
||||
|
||||
if (File.Exists(processedPath))
|
||||
{
|
||||
File.Delete(processedPath);
|
||||
|
||||
logger.Log(LogLevel.Warning,
|
||||
"File {torrentFileName} replaced in {errorStorePath} - it already existed and new torrent with same filename was added",
|
||||
fileInfo.Name,
|
||||
errorStorePath);
|
||||
}
|
||||
File.Move(torrentFile, processedPath);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue