private void Clean(string localDirectory, CmisRepo.SynchronizedFolder synchronizedFolder) { // Sync deletions to server. synchronizedFolder.Sync(); CleanAll(localDirectory); synchronizedFolder.Sync(); // Remove checkout folder. Directory.Delete(localDirectory); }
/// <summary> /// Waits the until sync is done. /// </summary> /// <returns> /// True, if checkStop has been true, otherwise false. /// </returns> /// <param name='synchronizedFolder'> /// Synchronized folder, which should be used for sync and waiting. /// </param> /// <param name='checkStop'> /// If returns <c>true</c> wait returns true, otherwise a retry will be executed until reaching maxTries. /// </param> /// <param name='maxTries'> /// Number of retries, until false is returned, if checkStop could not be true. /// </param> /// <param name='pollInterval'> /// Sleep interval duration in miliseconds between synchronization calls. /// </param> public static bool WaitUntilSyncIsDone(CmisRepo.SynchronizedFolder synchronizedFolder, Func<bool> checkStop, int maxTries = 4, int pollInterval = 5000) { int i = 0; while(i < maxTries) { try{ synchronizedFolder.Sync(); }catch(DotCMIS.Exceptions.CmisRuntimeException e){ Console.WriteLine("{0} Exception caught and swallowed, retry.", e); System.Threading.Thread.Sleep(pollInterval); continue; } if(checkStop()) return true; Console.WriteLine(String.Format("Retry Sync in {0}ms", pollInterval)); System.Threading.Thread.Sleep(pollInterval); i++; } Console.WriteLine("Sync call was not successful"); return false; }