Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/duplicati/duplicati.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'Duplicati/Library/Main/Database/LocalRepairDatabase.cs')
-rw-r--r--Duplicati/Library/Main/Database/LocalRepairDatabase.cs34
1 files changed, 18 insertions, 16 deletions
diff --git a/Duplicati/Library/Main/Database/LocalRepairDatabase.cs b/Duplicati/Library/Main/Database/LocalRepairDatabase.cs
index b10679f61..ed4236980 100644
--- a/Duplicati/Library/Main/Database/LocalRepairDatabase.cs
+++ b/Duplicati/Library/Main/Database/LocalRepairDatabase.cs
@@ -288,7 +288,7 @@ namespace Duplicati.Library.Main.Database
cmd.CommandText = sql_count;
x = cmd.ExecuteScalarInt64(0);
if (x > 1)
- throw new Exception("Repair failed, there are still duplicate metadatahashes!");
+ throw new Duplicati.Library.Interface.UserInformationException("Repair failed, there are still duplicate metadatahashes!");
m_result.AddMessage("Duplicate metadatahashes repaired succesfully");
tr.Commit();
@@ -323,7 +323,7 @@ namespace Duplicati.Library.Main.Database
cmd.CommandText = sql_count;
x = cmd.ExecuteScalarInt64(0);
if (x > 1)
- throw new Exception("Repair failed, there are still duplicate file entries!");
+ throw new Duplicati.Library.Interface.UserInformationException("Repair failed, there are still duplicate file entries!");
m_result.AddMessage("Duplicate file entries repaired succesfully");
tr.Commit();
@@ -334,7 +334,7 @@ namespace Duplicati.Library.Main.Database
public void FixMissingBlocklistHashes(string blockhashalgorithm, long blocksize)
{
- var blockhasher = System.Security.Cryptography.HashAlgorithm.Create(blockhashalgorithm);
+ var blockhasher = Library.Utility.HashAlgorithmHelper.Create(blockhashalgorithm);
var hashsize = blockhasher.HashSize / 8;
var blocklistbuffer = new byte[blocksize];
int blocklistoffset = 0;
@@ -429,7 +429,7 @@ namespace Duplicati.Library.Main.Database
itemswithnoblocklisthash = cmd.ExecuteScalarInt64(countsql, 0);
if (itemswithnoblocklisthash != 0)
- throw new Exception(string.Format("Failed to repair, after repair {0} blocklisthashes were missing", itemswithnoblocklisthash));
+ throw new Duplicati.Library.Interface.UserInformationException(string.Format("Failed to repair, after repair {0} blocklisthashes were missing", itemswithnoblocklisthash));
m_result.AddMessage("Missing blocklisthashes repaired succesfully");
tr.Commit();
@@ -474,15 +474,15 @@ namespace Duplicati.Library.Main.Database
var real_count = cmd.ExecuteScalarInt64(@"SELECT Count(*) FROM ""BlocklistHash""", 0);
if (real_count != unique_count)
- throw new Exception(string.Format("Failed to repair, result should have been {0} blocklist hashes, but result was {1} blocklist hashes", unique_count, real_count));
+ throw new Duplicati.Library.Interface.UserInformationException(string.Format("Failed to repair, result should have been {0} blocklist hashes, but result was {1} blocklist hashes", unique_count, real_count));
try
{
- VerifyConsistency(tr, blocksize, hashsize);
+ VerifyConsistency(tr, blocksize, hashsize, true);
}
catch(Exception ex)
{
- throw new Exception("Repaired blocklisthashes, but the database was broken afterwards, rolled back changes", ex);
+ throw new Duplicati.Library.Interface.UserInformationException("Repaired blocklisthashes, but the database was broken afterwards, rolled back changes", ex);
}
m_result.AddMessage("Duplicate blocklisthashes repaired succesfully");
@@ -558,17 +558,19 @@ ORDER BY
"
,blocksize, blockhashlength);
- var en = blocklist.GetEnumerator();
- foreach(var r in cmd.ExecuteReaderEnumerable(query, hash, length))
+ using (var en = blocklist.GetEnumerator())
{
- if (!en.MoveNext())
- throw new Exception(string.Format("Too few entries in source blocklist with hash {0}", hash));
- if (en.Current != r.GetString(0))
- throw new Exception(string.Format("Mismatch in blocklist with hash {0}", hash));
- }
+ foreach (var r in cmd.ExecuteReaderEnumerable(query, hash, length))
+ {
+ if (!en.MoveNext())
+ throw new Exception(string.Format("Too few entries in source blocklist with hash {0}", hash));
+ if (en.Current != r.GetString(0))
+ throw new Exception(string.Format("Mismatch in blocklist with hash {0}", hash));
+ }
- if (en.MoveNext())
- throw new Exception(string.Format("Too many source blocklist entries in {0}", hash));
+ if (en.MoveNext())
+ throw new Exception(string.Format("Too many source blocklist entries in {0}", hash));
+ }
}
}
}