Skip to content

Commit

Permalink
Include fileset file when repairing missing dlist file.
Browse files Browse the repository at this point in the history
This concerns issue duplicati#3982.
  • Loading branch information
warwickmm committed Nov 21, 2019
1 parent 8ab6407 commit 08a4ea2
Showing 1 changed file with 16 additions and 10 deletions.
26 changes: 16 additions & 10 deletions Duplicati/Library/Main/Operation/RepairHandler.cs
Expand Up @@ -23,11 +23,11 @@ public RepairHandler(string backend, Options options, RepairResults result)
m_backendurl = backend;
m_options = options;
m_result = result;

if (options.AllowPassphraseChange)
throw new UserInformationException(Strings.Common.PassphraseChangeUnsupported, "PassphraseChangeUnsupported");
}

public void Run(Library.Utility.IFilter filter = null)
{
if (!System.IO.File.Exists(m_options.Dbpath))
Expand Down Expand Up @@ -287,19 +287,25 @@ public void RunRepairRemote()
if (n.Type == RemoteVolumeType.Files)
{
var filesetId = db.GetFilesetIdFromRemotename(n.Name);
var w = new FilesetVolumeWriter(m_options, DateTime.UtcNow);
newEntry = w;
w.SetRemoteFilename(n.Name);

db.WriteFileset(w, filesetId, null);
// We cannot wrap the FilesetVolumeWriter in a using statement here because it might
// be disposed before the backend has completed the put operation. To ensure that
// the filelist.json is included in the dlist file, we must manually call Close below.
FilesetVolumeWriter volumeWriter = new FilesetVolumeWriter(m_options, DateTime.UtcNow);
newEntry = volumeWriter;
volumeWriter.SetRemoteFilename(n.Name);

db.WriteFileset(volumeWriter, filesetId, null);
DateTime filesetTime = db.FilesetTimes.First(x => x.Key == filesetId).Value;
volumeWriter.CreateFilesetFile(db.IsFilesetFullBackup(filesetTime));

w.Close();
volumeWriter.Close();
if (m_options.Dryrun)
Logging.Log.WriteDryrunMessage(LOGTAG, "WouldReUploadFileset", "would re-upload fileset {0}, with size {1}, previous size {2}", n.Name, Library.Utility.Utility.FormatSizeString(new System.IO.FileInfo(w.LocalFilename).Length), Library.Utility.Utility.FormatSizeString(n.Size));
Logging.Log.WriteDryrunMessage(LOGTAG, "WouldReUploadFileset", "would re-upload fileset {0}, with size {1}, previous size {2}", n.Name, Library.Utility.Utility.FormatSizeString(new System.IO.FileInfo(volumeWriter.LocalFilename).Length), Library.Utility.Utility.FormatSizeString(n.Size));
else
{
db.UpdateRemoteVolume(w.RemoteFilename, RemoteVolumeState.Uploading, -1, null, null);
backend.Put(w);
db.UpdateRemoteVolume(volumeWriter.RemoteFilename, RemoteVolumeState.Uploading, -1, null, null);
backend.Put(volumeWriter);
}
}
else if (n.Type == RemoteVolumeType.Index)
Expand Down

0 comments on commit 08a4ea2

Please sign in to comment.