public SparkleRepoBase(string path, SparkleBackend backend) { LocalPath = path; Name = Path.GetFileName (LocalPath); Backend = backend; this.poll_interval = this.short_interval; SyncStatusChanged += delegate (SyncStatus status) { this.status = status; }; CreateWatcher (); if (CurrentRevision == null) CreateInitialChangeSet (); CreateListener (); this.local_timer.Elapsed += delegate (object o, ElapsedEventArgs args) { CheckForChanges (); }; this.remote_timer.Elapsed += delegate { bool time_to_poll = (DateTime.Compare (this.last_poll, DateTime.Now.Subtract (this.poll_interval)) < 0); if (time_to_poll) { this.last_poll = DateTime.Now; if (CheckForRemoteChanges ()) SyncDownBase (); } // In the unlikely case that we haven't synced up our // changes or the server was down, sync up again if (HasUnsyncedChanges) { SyncUpBase (); SyncUpNotes (); } }; this.remote_timer.Start (); this.local_timer.Start (); // Sync up everything that changed // since we've been offline if (AnyDifferences) { DisableWatching (); SyncUpBase (); while (HasUnsyncedChanges) SyncUpBase (); EnableWatching (); } }
// TODO: constructor (path, url, backend) public SparkleRepoBase(string path, SparkleBackend backend) { LocalPath = path; Name = Path.GetFileName (LocalPath); Backend = backend; SyncStatusChanged += delegate (SyncStatus status) { this.status = status; }; if (CurrentRevision == null) { CreateInitialChangeSet (); HasUnsyncedChanges = true; } CreateWatcher (); CreateListener (); this.local_timer.Elapsed += delegate (object o, ElapsedEventArgs args) { CheckForChanges (); }; this.remote_timer.Elapsed += delegate { if (this.is_polling) { if (CheckForRemoteChanges ()) SyncDownBase (); } if (this.is_polling && !this.listener.IsConnecting && !this.listener.IsConnected) this.listener.Connect (); // In the unlikely case that we haven't synced up our // changes or the server was down, sync up again if (HasUnsyncedChanges) SyncUpBase (); }; this.remote_timer.Start (); this.local_timer.Start (); // Sync up everything that changed // since we've been offline if (AnyDifferences) { DisableWatching (); SyncUpBase (); while (HasUnsyncedChanges) SyncUpBase (); EnableWatching (); } }
public SparkleRepoHg(string path, SparkleBackend backend) : base(path, backend) { }