mirror of https://github.com/lidarr/Lidarr
Moving file from same source/destination no longer just deletes the file.
This commit is contained in:
parent
1c99541731
commit
19c087e50a
|
@ -48,6 +48,20 @@ namespace NzbDrone.Common.Test
|
||||||
File.Exists(targetPath).Should().BeTrue();
|
File.Exists(targetPath).Should().BeTrue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void moveFile_should_not_move_overwrite_itself()
|
||||||
|
{
|
||||||
|
var diskProvider = new DiskProvider();
|
||||||
|
diskProvider.CopyDirectory(BinFolder.FullName, BinFolderCopy.FullName);
|
||||||
|
|
||||||
|
var targetPath = BinFolderCopy.GetFiles("*.dll", SearchOption.AllDirectories).First().FullName;
|
||||||
|
|
||||||
|
diskProvider.MoveFile(targetPath, targetPath);
|
||||||
|
|
||||||
|
File.Exists(targetPath).Should().BeTrue();
|
||||||
|
ExceptionVerification.ExcpectedWarns(1);
|
||||||
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void CopyFolder_should_copy_folder()
|
public void CopyFolder_should_copy_folder()
|
||||||
{
|
{
|
||||||
|
|
|
@ -125,14 +125,20 @@ namespace NzbDrone.Common
|
||||||
File.Delete(path);
|
File.Delete(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual void MoveFile(string sourcePath, string destinationPath)
|
public virtual void MoveFile(string source, string destination)
|
||||||
{
|
{
|
||||||
if (FileExists(destinationPath))
|
if (PathEquals(source, destination))
|
||||||
{
|
{
|
||||||
DeleteFile(destinationPath);
|
Logger.Warn("Source and destination can't be the same {0}", source);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
File.Move(sourcePath, destinationPath);
|
if (FileExists(destination))
|
||||||
|
{
|
||||||
|
DeleteFile(destination);
|
||||||
|
}
|
||||||
|
|
||||||
|
File.Move(source, destination);
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual void DeleteFolder(string path, bool recursive)
|
public virtual void DeleteFolder(string path, bool recursive)
|
||||||
|
|
Loading…
Reference in New Issue