diff options
author | Kenneth Skovhede <kenneth@hexad.dk> | 2015-08-24 19:03:14 +0300 |
---|---|---|
committer | Kenneth Skovhede <kenneth@hexad.dk> | 2015-08-24 19:03:14 +0300 |
commit | 93cde1a674424da1d18df2e590598a2370498338 (patch) | |
tree | b20aea488763588d8956425d4b4b8ed7a7492fd3 | |
parent | e087dd340ceea330efa2387bf239543184d5f72b (diff) |
Added a probing method to better handle restore cases with renamed files.
This fixes #1437.
-rw-r--r-- | Duplicati/Library/Main/Operation/RecreateDatabaseHandler.cs | 48 |
1 files changed, 46 insertions, 2 deletions
diff --git a/Duplicati/Library/Main/Operation/RecreateDatabaseHandler.cs b/Duplicati/Library/Main/Operation/RecreateDatabaseHandler.cs index 356def2bc..b9d85e191 100644 --- a/Duplicati/Library/Main/Operation/RecreateDatabaseHandler.cs +++ b/Duplicati/Library/Main/Operation/RecreateDatabaseHandler.cs @@ -263,12 +263,28 @@ namespace Duplicati.Library.Main.Operation {
foreach(var a in svr.Volumes)
{
- var volumeID = restoredb.GetRemoteVolumeID(a.Filename);
+ var filename = a.Filename;
+ var volumeID = restoredb.GetRemoteVolumeID(filename);
+
+ // No such file
+ if (volumeID < 0)
+ volumeID = ProbeForMatchingFilename(ref filename, restoredb);
+
+ // Still broken, register a missing item
+ if (volumeID < 0)
+ {
+ var p = VolumeBase.ParseFilename(filename);
+ if (p == null)
+ throw new Exception(string.Format("Unable to parse filename: {0}", filename));
+ m_result.AddError(string.Format("Remote file referenced as {0}, but not found in list, registering a missing remote file", filename), null);
+ volumeID = restoredb.RegisterRemoteVolume(filename, p.FileType, RemoteVolumeState.Verified, tr);
+ }
+
//Add all block/volume mappings
foreach(var b in a.Blocks)
restoredb.UpdateBlock(b.Key, b.Value, volumeID, tr);
- restoredb.UpdateRemoteVolume(a.Filename, RemoteVolumeState.Verified, a.Length, a.Hash, tr);
+ restoredb.UpdateRemoteVolume(filename, RemoteVolumeState.Verified, a.Length, a.Hash, tr);
restoredb.AddIndexBlockLink(restoredb.GetRemoteVolumeID(sf.Name), volumeID, tr);
}
@@ -376,6 +392,34 @@ namespace Duplicati.Library.Main.Operation }
}
+ /// <summary>
+ /// Look in the database for filenames similar to the current filename, but with a different compression and encryption module
+ /// </summary>
+ /// <returns>The volume id of the item</returns>
+ /// <param name="filename">The filename read and written</param>
+ /// <param name="restoredb">The database to query</param>
+ public long ProbeForMatchingFilename(ref string filename, LocalRestoreDatabase restoredb)
+ {
+ var p = VolumeBase.ParseFilename(filename);
+ if (p != null)
+ {
+ foreach(var compmodule in Library.DynamicLoader.CompressionLoader.Keys)
+ foreach(var encmodule in Library.DynamicLoader.EncryptionLoader.Keys.Union(new string[] { "" }))
+ {
+ var testfilename = VolumeBase.GenerateFilename(p.FileType, p.Prefix, p.Guid, p.Time, compmodule, encmodule);
+ var tvid = restoredb.GetRemoteVolumeID(testfilename);
+ if (tvid >= 0)
+ {
+ m_result.AddWarning(string.Format("Unable to find volume {0}, but mapping to matching file {1}", filename, testfilename), null);
+ filename = testfilename;
+ return tvid;
+ }
+ }
+ }
+
+ return -1;
+ }
+
public void Dispose()
{
}
|