Added consistency check when re-building index files.

This commit is contained in:
Kenneth Skovhede
2016-02-23 20:56:58 +01:00
parent 39a8f4eb7f
commit e2c3ba91e6
@@ -239,6 +239,8 @@ namespace Duplicati.Library.Main.Operation
var w = new IndexVolumeWriter(m_options);
newEntry = w;
w.SetRemoteFilename(n.Name);
var h = System.Security.Cryptography.HashAlgorithm.Create(m_options.BlockHashAlgorithm);
foreach(var blockvolume in db.GetBlockVolumesFromIndexName(n.Name))
{
@@ -252,7 +254,13 @@ namespace Duplicati.Library.Main.Operation
if (m_options.IndexfilePolicy == Options.IndexFileStrategy.Full)
foreach(var b in db.GetBlocklists(volumeid, m_options.Blocksize, hashsize))
{
var bh = Convert.ToBase64String(h.ComputeHash(b.Item2, 0, b.Item3));
if (bh != b.Item1)
throw new Exception(string.Format("Internal consistency check failed, generated index block has wrong hash, {0} vs {1}", bh, b.Item1));
w.WriteBlocklist(b.Item1, b.Item2, 0, b.Item3);
}
}
w.Close();