Update issue #262

Status: Fixed

It turns out that the fix to enable filters disabled the --file-to-restore option.
I have fixed that and also updated the restore output to correctly reflect what has happened during the restore.

git-svn-id: https://duplicati.googlecode.com/svn/trunk@505 59da171f-624f-0410-aa54-27559c288bec
This commit is contained in:
kenneth.skovhede@gmail.com
2010-09-11 11:12:46 +00:00
parent de357ec4bc
commit 08a58bfdbb
3 changed files with 70 additions and 7 deletions
+2 -1
View File
@@ -40,7 +40,8 @@ namespace Duplicati.CommandLine
return;
}
options["filter"] = filter;
if (!string.IsNullOrEmpty(filter))
options["filter"] = filter;
//If we are on Windows, append the bundled "win-tools" programs to the search path
//We add it last, to allow the user to override with other versions
+32 -2
View File
@@ -1134,6 +1134,11 @@ namespace Duplicati.Library.Main.RSync
{
//TODO: Perhaps read ahead in patches to prevent creation
System.IO.Directory.Delete(s, false);
if (m_stat as RestoreStatistics != null)
{
(m_stat as RestoreStatistics).FoldersDeleted++;
(m_stat as RestoreStatistics).FoldersRestored--;
}
}
catch (Exception ex)
{
@@ -1273,7 +1278,15 @@ namespace Duplicati.Library.Main.RSync
try
{
//TODO: Perhaps read ahead in patches to prevent creation
long size = new FileInfo(s).Length;
System.IO.File.Delete(s);
if (m_stat as RestoreStatistics != null)
{
(m_stat as RestoreStatistics).FilesRestored--;
(m_stat as RestoreStatistics).SizeOfRestoredFiles -= size;
(m_stat as RestoreStatistics).FilesDeleted++;
}
}
catch (Exception ex)
{
@@ -1320,6 +1333,8 @@ namespace Duplicati.Library.Main.RSync
try
{
System.IO.Directory.CreateDirectory(s);
if (m_stat as RestoreStatistics != null)
(m_stat as RestoreStatistics).FoldersRestored++;
}
catch (Exception ex)
{
@@ -1411,6 +1426,12 @@ namespace Duplicati.Library.Main.RSync
partialFile.Dispose();
m_partialDeltas.Remove(s);
}
if (m_stat is RestoreStatistics && (partialFile == null || pex == fe))
{
(m_stat as RestoreStatistics).FilesRestored++;
(m_stat as RestoreStatistics).SizeOfRestoredFiles += new FileInfo(target).Length;
}
}
if (File.Exists(target))
@@ -1421,7 +1442,8 @@ namespace Duplicati.Library.Main.RSync
try { File.SetLastWriteTimeUtc(target, t); }
catch (Exception ex)
{
m_stat.LogWarning(string.Format(Strings.RSyncDir.FailedToSetFileWriteTime, target, ex.Message));
if (m_stat != null)
m_stat.LogWarning(string.Format(Strings.RSyncDir.FailedToSetFileWriteTime, target, ex.Message));
}
}
}
@@ -1496,6 +1518,13 @@ namespace Duplicati.Library.Main.RSync
using (System.IO.FileStream s3 = System.IO.File.Create(tempfile))
SharpRSync.Interface.PatchFile(s1, s2, s3);
if (m_stat as RestoreStatistics != null)
{
(m_stat as RestoreStatistics).SizeOfRestoredFiles -= new FileInfo(target).Length;
(m_stat as RestoreStatistics).SizeOfRestoredFiles += new FileInfo(tempfile).Length;
(m_stat as RestoreStatistics).FilesPatched++;
}
System.IO.File.Delete(target);
System.IO.File.Move(tempfile, target);
}
@@ -1509,7 +1538,8 @@ namespace Duplicati.Library.Main.RSync
try { File.SetLastWriteTimeUtc(target, t); }
catch (Exception ex)
{
m_stat.LogWarning(string.Format(Strings.RSyncDir.FailedToSetFileWriteTime, target, ex.Message));
if (m_stat != null)
m_stat.LogWarning(string.Format(Strings.RSyncDir.FailedToSetFileWriteTime, target, ex.Message));
}
}
}
+36 -4
View File
@@ -29,6 +29,10 @@ namespace Duplicati.Library.Main
private DateTime m_endTime;
private long m_filesRestored;
private long m_sizeOfRestoredFiles;
private long m_foldersRestored;
private long m_filesPatched;
private long m_filesDeleted;
private long m_foldersDeleted;
public RestoreStatistics()
{
@@ -49,7 +53,7 @@ namespace Duplicati.Library.Main
public TimeSpan Duration
{
get { return m_beginTime - m_endTime; }
get { return m_endTime - m_beginTime; }
}
public long FilesRestored
@@ -64,14 +68,42 @@ namespace Duplicati.Library.Main
set { m_sizeOfRestoredFiles = value; }
}
public long FoldersRestored
{
get { return m_foldersRestored; }
set { m_foldersRestored = value; }
}
public long FoldersDeleted
{
get { return m_foldersDeleted; }
set { m_foldersDeleted = value; }
}
public long FilesPatched
{
get { return m_filesPatched; }
set { m_filesPatched = value; }
}
public long FilesDeleted
{
get { return m_filesDeleted; }
set { m_filesDeleted = value; }
}
public override string ToString()
{
StringBuilder sb = new StringBuilder();
sb.AppendLine("BeginTime : " + this.BeginTime.ToString(System.Globalization.CultureInfo.InvariantCulture));
sb.AppendLine("EndTime : " + this.EndTime.ToString(System.Globalization.CultureInfo.InvariantCulture));
sb.AppendLine("Duration : " + this.Duration.ToString());
sb.AppendLine("Files restored : " + this.FilesRestored.ToString(System.Globalization.CultureInfo.InvariantCulture));
sb.AppendLine("Restored size : " + this.SizeOfRestoredFiles.ToString(System.Globalization.CultureInfo.InvariantCulture));
sb.AppendLine("Duration : " + this.Duration.ToString());
sb.AppendLine("Files restored : " + this.FilesRestored.ToString(System.Globalization.CultureInfo.InvariantCulture));
sb.AppendLine("Files patched : " + this.FilesPatched.ToString(System.Globalization.CultureInfo.InvariantCulture));
sb.AppendLine("Files deleted : " + this.FilesDeleted.ToString(System.Globalization.CultureInfo.InvariantCulture));
sb.AppendLine("Restored size : " + this.SizeOfRestoredFiles.ToString(System.Globalization.CultureInfo.InvariantCulture));
sb.AppendLine("Folders created : " + this.FoldersRestored.ToString(System.Globalization.CultureInfo.InvariantCulture));
sb.AppendLine("Folders deleted : " + this.FoldersDeleted.ToString(System.Globalization.CultureInfo.InvariantCulture));
sb.Append(base.ToString());
return sb.ToString();
}