mirror of
https://github.com/Radarr/Radarr
synced 2025-02-24 15:21:28 +00:00
Recompare file size after import file if necessary
(cherry picked from commit 6660db22ecf53d7747e3abc400529669ea779fa1)
This commit is contained in:
parent
8b7884deb0
commit
958a863d8f
1 changed files with 23 additions and 12 deletions
|
@ -474,12 +474,7 @@ private void TryCopyFileVerified(string sourcePath, string targetPath, long orig
|
|||
try
|
||||
{
|
||||
_diskProvider.CopyFile(sourcePath, targetPath);
|
||||
|
||||
var targetSize = _diskProvider.GetFileSize(targetPath);
|
||||
if (targetSize != originalSize)
|
||||
{
|
||||
throw new IOException(string.Format("File copy incomplete. [{0}] was {1} bytes long instead of {2} bytes.", targetPath, targetSize, originalSize));
|
||||
}
|
||||
VerifyFile(sourcePath, targetPath, originalSize, "copy");
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
@ -493,12 +488,7 @@ private void TryMoveFileVerified(string sourcePath, string targetPath, long orig
|
|||
try
|
||||
{
|
||||
_diskProvider.MoveFile(sourcePath, targetPath);
|
||||
|
||||
var targetSize = _diskProvider.GetFileSize(targetPath);
|
||||
if (targetSize != originalSize)
|
||||
{
|
||||
throw new IOException(string.Format("File move incomplete, data loss may have occurred. [{0}] was {1} bytes long instead of the expected {2}.", targetPath, targetSize, originalSize));
|
||||
}
|
||||
VerifyFile(sourcePath, targetPath, originalSize, "move");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
@ -511,6 +501,27 @@ private void TryMoveFileVerified(string sourcePath, string targetPath, long orig
|
|||
}
|
||||
}
|
||||
|
||||
private void VerifyFile(string sourcePath, string targetPath, long originalSize, string action)
|
||||
{
|
||||
var targetSize = _diskProvider.GetFileSize(targetPath);
|
||||
|
||||
if (targetSize == originalSize)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_logger.Debug("File {0} incomplete, waiting in case filesystem is not synchronized. [{1}] was {2} bytes long instead of the expected {3}.", action, targetPath, targetSize, originalSize);
|
||||
WaitForIO();
|
||||
targetSize = _diskProvider.GetFileSize(targetPath);
|
||||
|
||||
if (targetSize == originalSize)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
throw new IOException(string.Format("File {0} incomplete, data loss may have occurred. [{1}] was {2} bytes long instead of the expected {3}.", action, targetPath, targetSize, originalSize));
|
||||
}
|
||||
|
||||
private bool ShouldIgnore(DirectoryInfo folder)
|
||||
{
|
||||
if (folder.Name.StartsWith(".nfs"))
|
||||
|
|
Loading…
Reference in a new issue