public DeltaChain(DeltaManifest manifest) { if (manifest == null) throw new ArgumentNullException("manifest"); this.manifest = manifest; }
public Delta(DeltaManifest manifest, LinkedList<DeltaEntry> deltaEntries) { if (manifest == null) throw new ArgumentNullException("manifest"); if (deltaEntries == null) this.entries = new LinkedList<DeltaEntry>(); else this.entries = deltaEntries; this.manifest = manifest; this.timestamp = DateTime.Now; }
private void LoadOrCreateManifest() { ISiteAdapter adapter = profile.GetProvider().Adapter; if (!adapter.FileExists(profile, profile.RemoteHost)) FlagDatabaseDirty(); string packagePath = DeltaManifest.GetManifestPath(profile); if (!adapter.FileExists(profile, packagePath)) deltaManifest = new DeltaManifest(profile, GetDatabaseToken()); else using (Stream manifestStream = adapter.PullFile(profile, packagePath)) deltaManifest = DeltaManifest.Deserialize(manifestStream, profile); try { if (!deltaManifest.IsNew) { try { deltaManifest.Validate(); DeltaChain = new DeltaChain(deltaManifest); } // The manifest may belong to another db... catch (DeltaSyncException) { // Store the old manifest legacyManifest = deltaManifest; // Create new manifest deltaManifest = new DeltaManifest(profile, GetDatabaseToken()); // Inform the caller throw; } } } finally { // MUST run always, even if DeltaManifest.IsNew == TRUE CurrentDelta = new Delta(deltaManifest); } }
public Delta(DeltaManifest manifest) : this(manifest, null) { }
public static string GetPathForDelta(DeltaManifest manifest, int deltaIndex) { if (manifest == null) throw new ArgumentNullException("manifest"); return String.Format("{0}.d{1}.{2}", manifest.AssociatedProfile.RemoteHost, deltaIndex.ToString("000"), DeltaSuffix); }
public static Delta Deserialize(Stream source, DeltaManifest manifest) { if (source == null) throw new ArgumentNullException("source"); if (manifest == null) throw new ArgumentNullException("manifest"); if (!source.CanRead) throw new ArgumentException(); using (MemoryStream decryptedStream = new MemoryStream(8192)) { StreamUtility.DecryptAndDecompress(source, decryptedStream, manifest.AssociatedProfile.DatabasePassword); decryptedStream.Seek(0, SeekOrigin.Begin); BinaryFormatter formatter = new BinaryFormatter(); Delta delta = (Delta)formatter.Deserialize(decryptedStream); delta.manifest = manifest; return delta; } }