Fixed: NET Core not deleting source when moving across drives

This reverts commit 10fc0b071f.  Use the
mono fix from 43a35c8447 in NET Core also
This commit is contained in:
ta264
2020-05-14 21:01:23 +01:00
committed by Qstick
parent 5c9b85972d
commit d03a6486d3
3 changed files with 11 additions and 35 deletions
+3 -12
View File
@@ -227,18 +227,13 @@ namespace NzbDrone.Common.Disk
throw new IOException(string.Format("Source and destination can't be the same {0}", source));
}
var destExists = FileExists(destination);
if (destExists && overwrite)
if (FileExists(destination) && overwrite)
{
DeleteFile(destination);
}
RemoveReadOnly(source);
// NET Core is too eager to copy/delete if overwrite is false
// Therefore we also set overwrite if we know destination doesn't exist
MoveFileInternal(source, destination, overwrite || !destExists);
MoveFileInternal(source, destination);
}
public void MoveFolder(string source, string destination, bool overwrite = false)
@@ -260,13 +255,9 @@ namespace NzbDrone.Common.Disk
Directory.Move(source, destination);
}
protected virtual void MoveFileInternal(string source, string destination, bool overwrite)
protected virtual void MoveFileInternal(string source, string destination)
{
#if NETCOREAPP
File.Move(source, destination, overwrite);
#else
File.Move(source, destination);
#endif
}
public abstract bool TryCreateHardLink(string source, string destination);