mirror of
https://github.com/Readarr/Readarr.git
synced 2026-04-27 22:56:45 -04:00
Fixed: Renaming Episodes will never overwrite existing files.
This commit is contained in:
committed by
Mark McDowall
parent
125e69da6d
commit
e5e00fd346
@@ -84,10 +84,25 @@ namespace NzbDrone.Core.MediaFiles
|
||||
|
||||
else
|
||||
{
|
||||
var destination = Path.Combine(recyclingBin, new FileInfo(path).Name);
|
||||
var fileInfo = new FileInfo(path);
|
||||
var destination = Path.Combine(recyclingBin, fileInfo.Name);
|
||||
|
||||
var index = 1;
|
||||
while (_diskProvider.FileExists(destination))
|
||||
{
|
||||
index++;
|
||||
if (fileInfo.Extension.IsNullOrWhiteSpace())
|
||||
{
|
||||
destination = Path.Combine(recyclingBin, fileInfo.Name + "_" + index);
|
||||
}
|
||||
else
|
||||
{
|
||||
destination = Path.Combine(recyclingBin, Path.GetFileNameWithoutExtension(fileInfo.Name) + "_" + index + fileInfo.Extension);
|
||||
}
|
||||
}
|
||||
|
||||
logger.Debug("Moving '{0}' to '{1}'", path, destination);
|
||||
_diskProvider.MoveFile(path, destination);
|
||||
_diskProvider.MoveFile(path, destination, true);
|
||||
_diskProvider.FileSetLastWriteTimeUtc(destination, DateTime.UtcNow);
|
||||
logger.Debug("File has been moved to the recycling bin: {0}", destination);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user