Simplified getting list of files for restore
This commit is contained in:
@@ -285,9 +285,26 @@ namespace Duplicati.Library.Main.Database
|
||||
return new VolumePatchEnumerable(m_connection, m_tempfiletable, m_tempblocktable, m_blocksize, curvolume);
|
||||
}
|
||||
|
||||
private class FileToRestore : IFileToRestore
|
||||
{
|
||||
public string Path { get; private set; }
|
||||
public string Hash { get; private set; }
|
||||
public long ID { get; private set; }
|
||||
|
||||
public FileToRestore(long id, string path, string hash)
|
||||
{
|
||||
this.ID = id;
|
||||
this.Path = path;
|
||||
this.Hash = hash;
|
||||
}
|
||||
}
|
||||
|
||||
public IEnumerable<IFileToRestore> GetFilesToRestore()
|
||||
{
|
||||
return new FileToRestoreEnumerable(m_connection, m_tempfiletable);
|
||||
using(var cmd = m_connection.CreateCommand())
|
||||
using(var rd = cmd.ExecuteReader(string.Format(@"SELECT ""{0}"".""ID"", ""{0}"".""TargetPath"", ""Blockset"".""FullHash"" FROM ""{0}"",""Blockset"" WHERE ""{0}"".""BlocksetID"" = ""Blockset"".""ID"" ", m_tempfiletable)))
|
||||
while (rd.Read())
|
||||
yield return new FileToRestore(Convert.ToInt64(rd.GetValue(0)), rd.GetValue(1).ToString(), rd.GetValue(2).ToString());
|
||||
}
|
||||
|
||||
public void DropRestoreTable()
|
||||
|
||||
@@ -955,113 +955,6 @@ namespace Duplicati.Library.Main.Database
|
||||
}
|
||||
}
|
||||
|
||||
private class FileToRestoreEnumerable : IEnumerable<IFileToRestore>
|
||||
{
|
||||
private class FileToRestoreEnumerator : IEnumerator<IFileToRestore>
|
||||
{
|
||||
private class FileToRestore : IFileToRestore
|
||||
{
|
||||
private System.Data.IDataReader m_reader;
|
||||
public FileToRestore(System.Data.IDataReader reader)
|
||||
{
|
||||
m_reader = reader;
|
||||
}
|
||||
|
||||
public string Path
|
||||
{
|
||||
get
|
||||
{
|
||||
var v = m_reader.GetValue(0);
|
||||
if (v == null || v == DBNull.Value)
|
||||
return null;
|
||||
return v.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
public string Hash
|
||||
{
|
||||
get
|
||||
{
|
||||
var v = m_reader.GetValue(1);
|
||||
if (v == null || v == DBNull.Value)
|
||||
return null;
|
||||
return v.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private System.Data.IDbConnection m_connection;
|
||||
private System.Data.IDataReader m_reader;
|
||||
private System.Data.IDbCommand m_command;
|
||||
private string m_tablename;
|
||||
private FileToRestore m_file;
|
||||
|
||||
public FileToRestoreEnumerator(System.Data.IDbConnection connection, string tablename)
|
||||
{
|
||||
m_connection = connection;
|
||||
m_tablename = tablename;
|
||||
this.Reset();
|
||||
}
|
||||
|
||||
public IFileToRestore Current
|
||||
{
|
||||
get { return m_file; }
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
if (m_reader != null)
|
||||
{
|
||||
m_reader.Dispose();
|
||||
m_reader = null;
|
||||
}
|
||||
|
||||
if (m_command != null)
|
||||
{
|
||||
m_command.Dispose();
|
||||
m_command = null;
|
||||
}
|
||||
}
|
||||
|
||||
object System.Collections.IEnumerator.Current
|
||||
{
|
||||
get { return this.Current; }
|
||||
}
|
||||
|
||||
public bool MoveNext()
|
||||
{
|
||||
return m_reader.Read();
|
||||
}
|
||||
|
||||
public void Reset()
|
||||
{
|
||||
m_command = m_connection.CreateCommand();
|
||||
m_command.CommandText = string.Format(@"SELECT ""{0}"".""TargetPath"", ""Blockset"".""FullHash"" FROM ""{0}"",""Blockset"" WHERE ""{0}"".""BlocksetID"" = ""Blockset"".""ID"" ", m_tablename);
|
||||
m_reader = m_command.ExecuteReader();
|
||||
m_file = new FileToRestore(m_reader);
|
||||
}
|
||||
}
|
||||
|
||||
private System.Data.IDbConnection m_connection;
|
||||
private string m_tablename;
|
||||
|
||||
public FileToRestoreEnumerable(System.Data.IDbConnection connection, string tablename)
|
||||
{
|
||||
m_connection = connection;
|
||||
m_tablename = tablename;
|
||||
}
|
||||
|
||||
public IEnumerator<IFileToRestore> GetEnumerator()
|
||||
{
|
||||
return new FileToRestoreEnumerator(m_connection, m_tablename);
|
||||
}
|
||||
|
||||
System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
|
||||
{
|
||||
return this.GetEnumerator();
|
||||
}
|
||||
}
|
||||
|
||||
private class FolderListEnumerable : IEnumerable<string>
|
||||
{
|
||||
private class FolderListEnumerator : IEnumerator<string>
|
||||
|
||||
Reference in New Issue
Block a user