mirror of
https://github.com/Radarr/Radarr
synced 2026-04-28 14:51:15 +02:00
Moving file from same source/destination no longer just deletes the file.
This commit is contained in:
parent
1c99541731
commit
19c087e50a
2 changed files with 24 additions and 4 deletions
|
|
@ -48,6 +48,20 @@ public void moveFile_should_overwrite_existing_file()
|
|||
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]
|
||||
public void CopyFolder_should_copy_folder()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -125,14 +125,20 @@ public virtual void DeleteFile(string 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)
|
||||
|
|
|
|||
Loading…
Reference in a new issue