mirror of
https://github.com/Readarr/Readarr.git
synced 2026-04-22 22:14:44 -04:00
Fixed: Renaming episodes on OSX with case-insensitive filesystem.
This commit is contained in:
@@ -83,11 +83,35 @@ namespace NzbDrone.Common.Disk
|
||||
|
||||
_logger.Debug("{0} [{1}] > [{2}]", mode, sourcePath, targetPath);
|
||||
|
||||
if (sourcePath.PathEquals(targetPath))
|
||||
if (sourcePath == targetPath)
|
||||
{
|
||||
throw new IOException(string.Format("Source and destination can't be the same {0}", sourcePath));
|
||||
}
|
||||
|
||||
if (sourcePath.PathEquals(targetPath, StringComparison.InvariantCultureIgnoreCase))
|
||||
{
|
||||
if (mode.HasFlag(TransferMode.HardLink) || mode.HasFlag(TransferMode.Copy))
|
||||
{
|
||||
throw new IOException(string.Format("Source and destination can't be the same {0}", sourcePath));
|
||||
}
|
||||
|
||||
if (mode.HasFlag(TransferMode.Move))
|
||||
{
|
||||
var tempPath = sourcePath + ".backup~";
|
||||
_diskProvider.MoveFile(sourcePath, tempPath);
|
||||
|
||||
if (_diskProvider.FileExists(targetPath))
|
||||
{
|
||||
_diskProvider.MoveFile(tempPath, sourcePath);
|
||||
}
|
||||
|
||||
_diskProvider.MoveFile(tempPath, targetPath);
|
||||
return TransferMode.Move;
|
||||
}
|
||||
|
||||
return TransferMode.None;
|
||||
}
|
||||
|
||||
if (sourcePath.IsParentPath(targetPath))
|
||||
{
|
||||
throw new IOException(string.Format("Destination cannot be a child of the source [{0}] => [{1}]", sourcePath, targetPath));
|
||||
@@ -220,6 +244,10 @@ namespace NzbDrone.Common.Disk
|
||||
if (targetSize == originalSize)
|
||||
{
|
||||
_diskProvider.MoveFile(tempTargetPath, targetPath);
|
||||
if (_diskProvider.FileExists(tempTargetPath))
|
||||
{
|
||||
throw new IOException(String.Format("Temporary file '{0}' still exists, aborting.", tempTargetPath));
|
||||
}
|
||||
_logger.Trace("Hardlink move succeeded, deleting source.");
|
||||
_diskProvider.DeleteFile(sourcePath);
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user