/// <summary> /// Releases the resources associated with the archive /// </summary> public void Dispose() { if (this.backupIndex != null) this.backupIndex.Dispose(); if (this.restoreIndex != null) this.restoreIndex.Dispose(); if (this.tempIndex != null) this.tempIndex.Dispose(); this.backupIndex = null; this.restoreIndex = null; this.tempIndex = null; }
/// <summary> /// Opens an existing backup archive /// </summary> public void Open() { try { // copy the backup index to a temporary location and open it this.tempIndex = IO.FileSystem.Temp(); IO.FileSystem.Copy(this.IndexPath, this.tempIndex.Path); this.backupIndex = Sqlite.BackupIndex.Open(this.tempIndex.Path); } catch { Dispose(); throw; } }
/// <summary> /// Creates a new backup archive /// </summary> /// <param name="header"> /// The backup index header to insert /// </param> public void Create(Backup.Header header) { try { // create the archive directory IO.FileSystem.CreateDirectory(this.Path); // create the backup index within the temp path this.tempIndex = IO.FileSystem.Temp(); this.backupIndex = Sqlite.BackupIndex.Create(this.tempIndex.Path, header); this.backupIndex.InsertBlob( new Backup.Blob() { Name = this.BlobPath.FileName } ); // copy the initial version of the index to the archive path Save(); } catch { Dispose(); try { IO.FileSystem.Delete(this.Path); } catch { } throw; } }