Added a protection against partial downloads

git-svn-id: https://duplicati.googlecode.com/svn/trunk@941 59da171f-624f-0410-aa54-27559c288bec
This commit is contained in:
kenneth.skovhede@gmail.com
2011-10-22 14:55:06 +00:00
parent 652e02d64e
commit 41b1a5ad4a
4 changed files with 22 additions and 1 deletions
@@ -249,6 +249,10 @@ namespace Duplicati.CommandLine.BackendTester
Console.WriteLine("*** File with name {0} was found more than once", tx.filename);
found = true;
tx.found = true;
if (fe.Size > 0 && tx.length != fe.Size)
Console.WriteLine("*** File with name {0} has size {1} but the size was reported as {2}", tx.filename, tx.length, fe.Size);
break;
}
+5
View File
@@ -960,6 +960,11 @@ namespace Duplicati.Library.Main
ProgressEvent(100, m_statusmessage);
}
//This is required so we are sure that the file was downloaded completely and not partially,
// as any exception here will cause a retry, but using a partial file may cause random errors
if (remote.Fileentry.Size > 0 && remote.Fileentry.Size != new System.IO.FileInfo(tempfile).Length)
throw new Exception(string.Format(Strings.BackendWrapper.DownloadedFileSizeError, remote.Filename, remote.Fileentry.Size, new System.IO.FileInfo(tempfile).Length));
remote.RemoteHash = Utility.Utility.CalculateHash(tempfile);
//Manifest version 3 has hashes WITH encryption
+10 -1
View File
@@ -1,7 +1,7 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.237
// Runtime Version:4.0.30319.239
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
@@ -105,6 +105,15 @@ namespace Duplicati.Library.Main.Strings {
}
}
/// <summary>
/// Looks up a localized string similar to The file {0} was downloaded and had size {1} but the size was expected to be {2}.
/// </summary>
internal static string DownloadedFileSizeError {
get {
return ResourceManager.GetString("DownloadedFileSizeError", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to The file {0} was found multiple times in the file list, this is likely an error in the backend, please report it to the developers.
/// </summary>
@@ -204,4 +204,7 @@
<data name="FailureWhileDisposingBackendError" xml:space="preserve">
<value>An error occured while closing a connection: {0}</value>
</data>
<data name="DownloadedFileSizeError" xml:space="preserve">
<value>The file {0} was downloaded and had size {1} but the size was expected to be {2}</value>
</data>
</root>