Likely fix for issue #1644 and #1583

This commit is contained in:
Kenneth Skovhede
2016-03-24 16:30:19 +01:00
parent ebf6bbee74
commit 6cd73c1d0a
2 changed files with 16 additions and 4 deletions
@@ -156,9 +156,16 @@ namespace Duplicati.Library.Main.Database
}
public void UpdateRemoteVolume(string name, RemoteVolumeState state, long size, string hash, System.Data.IDbTransaction transaction = null)
{ UpdateRemoteVolume(name, state, size, hash, false, transaction); }
{
UpdateRemoteVolume(name, state, size, hash, false, transaction);
}
public void UpdateRemoteVolume(string name, RemoteVolumeState state, long size, string hash, bool suppressCleanup, System.Data.IDbTransaction transaction = null)
public void UpdateRemoteVolume(string name, RemoteVolumeState state, long size, string hash, bool suppressCleanup, System.Data.IDbTransaction transaction = null)
{
UpdateRemoteVolume(name, state, size, hash, suppressCleanup, new TimeSpan(0), transaction);
}
public void UpdateRemoteVolume(string name, RemoteVolumeState state, long size, string hash, bool suppressCleanup, TimeSpan deleteGraceTime, System.Data.IDbTransaction transaction = null)
{
m_updateremotevolumeCommand.Transaction = transaction;
m_updateremotevolumeCommand.SetParameterValue(0, m_operationid);
@@ -170,6 +177,12 @@ namespace Duplicati.Library.Main.Database
if (c != 1)
throw new Exception(string.Format("Unexpected number of remote volumes detected: {0}!", c));
if (deleteGraceTime.Ticks > 0)
using(var cmd = m_connection.CreateCommand(transaction))
if ((c = cmd.ExecuteNonQuery(@"UPDATE ""RemoteVolume"" SET ""DeleteGraceTime"" = ? WHERE ""Name"" = ? ", (DateTime.UtcNow + deleteGraceTime).Ticks, name)) != 1)
throw new Exception(string.Format("Unexpected number of remote volumes detected: {0}!", c));
if (!suppressCleanup && state == RemoteVolumeState.Deleted)
RemoveRemoteVolume(name, transaction);
}
@@ -282,8 +282,7 @@ namespace Duplicati.Library.Main.Operation
{
log.AddMessage(string.Format("scheduling missing file for deletion, currently listed as {0}: {1}", i.State, i.Name));
cleanupRemovedRemoteVolumes.Add(i.Name);
database.RegisterRemoteVolume(i.Name, i.Type, RemoteVolumeState.Deleting, TimeSpan.FromHours(2), null);
database.UpdateRemoteVolume(i.Name, RemoteVolumeState.Deleting, i.Size, i.Hash, null);
database.UpdateRemoteVolume(i.Name, RemoteVolumeState.Deleting, i.Size, i.Hash, false, TimeSpan.FromHours(2), null);
}
else
{