TaskEx.Run(() => _moves.AddOrUpdate(args.OldFullPath, args,(s,e)=>e)); \r
}\r
\r
+\r
+ private bool _hasConnection;\r
+\r
/// <summary>\r
/// Remote files are polled periodically. Any changes are processed\r
/// </summary>\r
\r
//GC.Collect();\r
\r
+ \r
using (ThreadContext.Stacks["Retrieve Remote"].Push("All accounts"))\r
{\r
//If this poll fails, we will retry with the same since value\r
_unPauseEvent.Wait();\r
UpdateStatus(PithosStatus.PollSyncing);\r
\r
- var accountBatches=new Dictionary<Uri, IEnumerable<string>>();\r
- IEnumerable<string> batch = null;\r
- if (_batchQueue.TryDequeue(out batch) && batch != null)\r
- foreach (var account in _accounts.Values)\r
+ if (!NetworkAgent.IsConnectedToInternet)\r
+ {\r
+ if (_hasConnection)\r
{\r
- var accountBatch = batch.Where(path => path.IsAtOrBelow(account.AccountPath));\r
- accountBatches[account.AccountKey] = accountBatch;\r
+ StatusNotification.Notify(new Notification\r
+ {\r
+ Level = TraceLevel.Error,\r
+ Title = "Internet Connection problem",\r
+ Message ="Internet connectivity was lost. Synchronization will continue when connectivity is restored"\r
+ });\r
}\r
- \r
- var moves=Interlocked.Exchange(ref _moves, new ConcurrentDictionary<string, MovedEventArgs>());\r
-\r
- var tasks = new List<Task<DateTimeOffset?>>();\r
- foreach(var accountInfo in _accounts.Values)\r
- {\r
- IEnumerable<string> accountBatch ;\r
- accountBatches.TryGetValue(accountInfo.AccountKey,out accountBatch);\r
- var t=ProcessAccountFiles (accountInfo, accountBatch, moves,since);\r
- tasks.Add(t);\r
+ _hasConnection = false;\r
}\r
+ else\r
+ {\r
+ _hasConnection = true;\r
\r
- var taskList = tasks.ToList();\r
- var nextTimes=await TaskEx.WhenAll(taskList).ConfigureAwait(false);\r
+ var accountBatches = new Dictionary<Uri, IEnumerable<string>>();\r
+ IEnumerable<string> batch = null;\r
+ if (_batchQueue.TryDequeue(out batch) && batch != null)\r
+ foreach (var account in _accounts.Values)\r
+ {\r
+ var accountBatch = batch.Where(path => path.IsAtOrBelow(account.AccountPath));\r
+ accountBatches[account.AccountKey] = accountBatch;\r
+ }\r
\r
- _firstPoll = false;\r
- //Reschedule the poll with the current timestamp as a "since" value\r
+ var moves = Interlocked.Exchange(ref _moves, new ConcurrentDictionary<string, MovedEventArgs>());\r
\r
- if (nextTimes.Length>0)\r
- nextSince = nextTimes.Min();\r
- if (Log.IsDebugEnabled)\r
- Log.DebugFormat("Next Poll for changes since [{0}]",nextSince);\r
+ var tasks = new List<Task<DateTimeOffset?>>();\r
+ foreach (var accountInfo in _accounts.Values)\r
+ {\r
+ IEnumerable<string> accountBatch;\r
+ accountBatches.TryGetValue(accountInfo.AccountKey, out accountBatch);\r
+ var t = ProcessAccountFiles(accountInfo, accountBatch, moves, since);\r
+ tasks.Add(t);\r
+ }\r
+\r
+ var taskList = tasks.ToList();\r
+ var nextTimes = await TaskEx.WhenAll(taskList).ConfigureAwait(false);\r
+\r
+ _firstPoll = false;\r
+ //Reschedule the poll with the current timestamp as a "since" value\r
+\r
+ if (nextTimes.Length > 0)\r
+ nextSince = nextTimes.Min();\r
+ if (Log.IsDebugEnabled)\r
+ Log.DebugFormat("Next Poll for changes since [{0}]", nextSince);\r
+ }\r
}\r
catch (Exception ex)\r
{\r