|
|
@ -234,13 +234,18 @@ namespace NzbDrone.Common.Disk
|
|
|
|
throw new IOException(string.Format("Source and destination can't be the same {0}", source));
|
|
|
|
throw new IOException(string.Format("Source and destination can't be the same {0}", source));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (FileExists(destination) && overwrite)
|
|
|
|
var destExists = FileExists(destination);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (destExists && overwrite)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
DeleteFile(destination);
|
|
|
|
DeleteFile(destination);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
RemoveReadOnly(source);
|
|
|
|
RemoveReadOnly(source);
|
|
|
|
MoveFileInternal(source, destination);
|
|
|
|
|
|
|
|
|
|
|
|
// 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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void MoveFolder(string source, string destination)
|
|
|
|
public void MoveFolder(string source, string destination)
|
|
|
@ -251,9 +256,15 @@ namespace NzbDrone.Common.Disk
|
|
|
|
Directory.Move(source, destination);
|
|
|
|
Directory.Move(source, destination);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
protected virtual void MoveFileInternal(string source, string destination)
|
|
|
|
protected virtual void MoveFileInternal(string source, string destination, bool overwrite)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
#if NETCOREAPP
|
|
|
|
|
|
|
|
// This is a hack but the netcore specific overwrite parameter
|
|
|
|
|
|
|
|
// isn't availaboe via system.io.abstractions
|
|
|
|
|
|
|
|
File.Move(source, destination, overwrite);
|
|
|
|
|
|
|
|
#else
|
|
|
|
_fileSystem.File.Move(source, destination);
|
|
|
|
_fileSystem.File.Move(source, destination);
|
|
|
|
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public abstract bool TryCreateHardLink(string source, string destination);
|
|
|
|
public abstract bool TryCreateHardLink(string source, string destination);
|
|
|
|