Пример #1
0
 /// <summary>
 /// Creates a new backup index
 /// </summary>
 /// <param name="path">
 /// The path to the backup index file to create
 /// </param>
 /// <param name="header">
 /// The backup index header to insert
 /// </param>
 /// <returns>
 /// A new backup index implementation
 /// </returns>
 public static IBackupIndex Create(IO.Path path, Header header)
 {
     // create the backup index file and schema
      Database.Create(path, "SkyFloe.Sqlite.Resources.BackupIndex.sql");
      var index = (BackupIndex)null;
      try
      {
     // connect to the database and add the header row
     index = new BackupIndex(path);
     index.Execute(
        "INSERT INTO Header (" +
        "   Version, " +
        "   CryptoIterations, " +
        "   ArchiveSalt, " +
        "   PasswordHash, " +
        "   PasswordSalt) " +
        "VALUES (@p0, @p1, @p2, @p3, @p4);",
        header.Version = CurrentVersion,
        header.CryptoIterations,
        header.ArchiveSalt,
        header.PasswordHash,
        header.PasswordSalt
     );
     return index;
      }
      catch
      {
     if (index != null)
        index.Dispose();
     try { Database.Delete(path); } catch { }
     throw;
      }
 }
Пример #2
0
 /// <summary>
 /// Connects to an existing backup index database
 /// </summary>
 /// <param name="path">
 /// The path to the backup index to open
 /// </param>
 /// <returns>
 /// A new backup index implementation
 /// </returns>
 public static IBackupIndex Open(IO.Path path)
 {
     BackupIndex index = new BackupIndex(path);
      if (index.FetchHeader().Version != CurrentVersion)
     throw new InvalidOperationException("Invalid database version");
      return index;
 }