private bool SynchronizeFolder(MailboxSession mailboxSession, LocalFolder localFolder, ItemSynchronizer itemSynchronizer) { BaseFolderType folder = this.GetFolder(mailboxSession, localFolder); this.ActualLevelOfDetails = new SharingLevelOfDetails(folder); this.OriginalLevelOfDetails = new SharingLevelOfDetails(localFolder.LoadLevelOfDetails()); if (this.OriginalLevelOfDetails == LevelOfDetails.None) { SharingEngine.Tracer.TraceDebug <SharingEngine, SharingLevelOfDetails>((long)this.GetHashCode(), "{0}: Access level changed from None to {1}. Saving the actual access level.", this, this.ActualLevelOfDetails); localFolder.SaveLevelOfDetails(this.ActualLevelOfDetails); } if (this.ActualLevelOfDetails == LevelOfDetails.None) { SharingEngine.Tracer.TraceDebug <LocalFolder>((long)this.GetHashCode(), "{0}: Permissions revoked for this folder.", localFolder); localFolder.DeleteAllItems(); localFolder.DeleteSyncState(); localFolder.SaveLevelOfDetails(this.ActualLevelOfDetails); SharingEngine.Tracer.TraceDebug <LocalFolder>((long)this.GetHashCode(), "{0}: All items have been deleted.", localFolder); SharingLog.LogEntry(mailboxSession, "User no longer has permissions to the publisher's folder. All items have been removed."); return(true); } if (this.ActualLevelOfDetails > this.OriginalLevelOfDetails) { SharingEngine.Tracer.TraceDebug <SharingEngine>((long)this.GetHashCode(), "{0}: Permission to the remote folder has increased. Resetting the sync state.", this); this.SyncState = null; localFolder.DeleteSyncState(); } SharingLog.LogEntry(mailboxSession, "Current permissions to the publisher's folder: " + this.ActualLevelOfDetails); return(this.SynchronizeFolderItems(mailboxSession, localFolder, itemSynchronizer)); }
private bool SynchronizeFolderItems(MailboxSession mailboxSession, LocalFolder localFolder, ItemSynchronizer itemSynchronizer) { bool result = false; SharingEngine.Tracer.TraceDebug <SharingEngine>((long)this.GetHashCode(), "{0}: Start syncing folder", this); try { while (this.BatchSync(mailboxSession, localFolder, itemSynchronizer)) { if (this.Deadline.IsOver) { SharingEngine.Tracer.TraceDebug <SharingEngine>((long)this.GetHashCode(), "{0}: Timed out while syncing new items.", this); break; } } } finally { localFolder.DeleteSelectedItems(); } this.EnforceLevelOfDetails(mailboxSession, localFolder, itemSynchronizer); localFolder.SaveLevelOfDetails(this.ActualLevelOfDetails); SharingEngine.Tracer.TraceDebug <SharingEngine>((long)this.GetHashCode(), "{0}: End syncing folder", this); if (!this.Deadline.IsOver) { result = true; localFolder.UpdateLastSyncTimes(); SharingLog.LogEntry(mailboxSession, "Synchronization completed."); } return(result); }