Skip to content

Commit

Permalink
Merge pull request #4042 from seantempleton/stopnowexceptions
Browse files Browse the repository at this point in the history
Fix database corruptions that can occur with "stop now".

This was a source of the "Detected non-empty blocksets with no associated blocks!" exception.
  • Loading branch information
warwickmm committed Jan 6, 2020
2 parents df2c70e + 3b6306b commit 52929e9
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Duplicati/Library/Main/Database/LocalDatabase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,7 @@ public void RemoveRemoteVolumes(IEnumerable<string> names, System.Data.IDbTransa
deletecmd.ExecuteNonQuery(string.Format(@"DELETE FROM ""Blockset"" WHERE ""ID"" IN ({0})", bsIdsSubQuery));
deletecmd.ExecuteNonQuery(string.Format(@"DELETE FROM ""BlocksetEntry"" WHERE ""BlocksetID"" IN ({0})", bsIdsSubQuery));

deletecmd.ExecuteNonQuery(string.Format(@"DELETE FROM ""BlocklistHash"" WHERE ""Hash"" IN (SELECT ""Hash"" FROM ""Block"" WHERE ""VolumeID"" IN ({0}))", volIdsSubQuery));
deletecmd.ExecuteNonQuery(string.Format(@"DELETE FROM ""BlocklistHash"" WHERE ""BlocklistHash"".""BlocksetID"" IN ({0})", bsIdsSubQuery));
deletecmd.ExecuteNonQuery(string.Format(@"DELETE FROM ""Block"" WHERE ""VolumeID"" IN ({0})", volIdsSubQuery));
deletecmd.ExecuteNonQuery(string.Format(@"DELETE FROM ""DeletedBlock"" WHERE ""VolumeID"" IN ({0})", volIdsSubQuery));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,12 @@ public static Task Run(BackupDatabase database, Options options, ITaskReader tas
}
var uploadRequest = new VolumeUploadRequest(blockvolume, blockEntry, indexVolumeCopy, options, database);
await self.Output.WriteAsync(uploadRequest);
blockvolume = null;
indexvolume = null;
// Write to output at the end here to prevent sending a full volume to the SpillCollector
await self.Output.WriteAsync(uploadRequest);
}
}
Expand Down
2 changes: 1 addition & 1 deletion Duplicati/Library/Utility/RegistryUtility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public static string GetDataByValueName(string parentKeyName, string name)
}

var lmParentKey = Registry.LocalMachine.OpenSubKey(parentKeyName, RegistryKeyPermissionCheck.ReadSubTree);
return lmParentKey.GetValue(name).ToString();
return lmParentKey?.GetValue(name).ToString();
}
catch
{
Expand Down

0 comments on commit 52929e9

Please sign in to comment.