Fixed: Renaming episodes on OSX with case-insensitive filesystem.

This commit is contained in:
Taloth Saldono
2015-06-27 01:01:33 +02:00
parent bd222dbd95
commit c9f720885e
3 changed files with 89 additions and 8 deletions
@@ -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;