Revision eae84ae8 trunk/Pithos.Core/Agents/NetworkAgent.cs
b/trunk/Pithos.Core/Agents/NetworkAgent.cs | ||
---|---|---|
120 | 120 |
throw new ArgumentException("The action.AccountInfo is empty","action"); |
121 | 121 |
Contract.EndContractBlock(); |
122 | 122 |
|
123 |
StatusKeeper.SetPithosStatus(PithosStatus.Syncing);
|
|
123 |
UpdateStatus(PithosStatus.Syncing);
|
|
124 | 124 |
var accountInfo = action.AccountInfo; |
125 | 125 |
|
126 | 126 |
using (log4net.ThreadContext.Stacks["NETWORK"].Push("PROCESS")) |
... | ... | |
131 | 131 |
var downloadPath = action.GetDownloadPath(); |
132 | 132 |
|
133 | 133 |
try |
134 |
{ |
|
135 |
|
|
134 |
{ |
|
136 | 135 |
if (action.Action == CloudActionType.DeleteCloud) |
137 |
{ |
|
136 |
{
|
|
138 | 137 |
//Redirect deletes to the delete agent |
139 | 138 |
_deleteAgent.Post((CloudDeleteAction)action); |
140 | 139 |
} |
... | ... | |
205 | 204 |
} |
206 | 205 |
finally |
207 | 206 |
{ |
208 |
StatusKeeper.SetPithosStatus(PithosStatus.InSynch);
|
|
207 |
UpdateStatus(PithosStatus.InSynch);
|
|
209 | 208 |
} |
210 | 209 |
} |
211 | 210 |
} |
212 | 211 |
|
212 |
private void UpdateStatus(PithosStatus status) |
|
213 |
{ |
|
214 |
StatusKeeper.SetPithosStatus(status); |
|
215 |
StatusNotification.Notify(new Notification()); |
|
216 |
} |
|
217 |
|
|
213 | 218 |
/// <summary> |
214 | 219 |
/// Processes cloud delete actions |
215 | 220 |
/// </summary> |
... | ... | |
382 | 387 |
Contract.EndContractBlock(); |
383 | 388 |
|
384 | 389 |
StatusKeeper.SetFileOverlayStatus(downloadPath, FileOverlayStatus.Conflict); |
385 |
StatusKeeper.SetPithosStatus(PithosStatus.HasConflicts);
|
|
390 |
UpdateStatus(PithosStatus.HasConflicts);
|
|
386 | 391 |
var message = String.Format("Conflict detected for file {0}", downloadPath); |
387 | 392 |
Log.Warn(message); |
388 | 393 |
StatusNotification.NotifyChange(message, TraceLevel.Warning); |
... | ... | |
442 | 447 |
public void SynchNow() |
443 | 448 |
{ |
444 | 449 |
if (_tcs!=null) |
445 |
_tcs.SetResult(true); |
|
450 |
_tcs.TrySetResult(true);
|
|
446 | 451 |
else |
447 | 452 |
{ |
448 | 453 |
//TODO: This may be OK for testing purposes, but we have no guarantee that it will |
... | ... | |
454 | 459 |
//Remote files are polled periodically. Any changes are processed |
455 | 460 |
public async Task PollRemoteFiles(DateTime? since = null,bool repeat=true) |
456 | 461 |
{ |
457 |
StatusNotification.Notify(new Notification{Title="Polling Pithos"});
|
|
458 |
StatusKeeper.SetPithosStatus(PithosStatus.Syncing);
|
|
462 |
UpdateStatus(PithosStatus.Syncing);
|
|
463 |
StatusNotification.Notify(new PollNotification());
|
|
459 | 464 |
|
460 | 465 |
using (log4net.ThreadContext.Stacks["Retrieve Remote"].Push("All accounts")) |
461 | 466 |
{ |
... | ... | |
484 | 489 |
Log.ErrorFormat("Error while processing accounts\r\n{0}",ex); |
485 | 490 |
//In case of failure retry with the same "since" value |
486 | 491 |
} |
487 |
|
|
492 |
|
|
493 |
UpdateStatus(PithosStatus.InSynch); |
|
488 | 494 |
//Wait for the polling interval to pass or the Manual flat to be toggled |
489 | 495 |
nextSince = await WaitForScheduledOrManualPoll(nextSince); |
490 | 496 |
|
... | ... | |
512 | 518 |
throw new ArgumentException("The AccountInfo.AccountPath is empty","accountInfo"); |
513 | 519 |
Contract.EndContractBlock(); |
514 | 520 |
|
515 |
StatusNotification.Notify(new Notification{Title=String.Format("Polling {0}",accountInfo.UserName)}); |
|
516 | 521 |
|
517 | 522 |
using (log4net.ThreadContext.Stacks["Retrieve Remote"].Push(accountInfo.UserName)) |
518 | 523 |
{ |
... | ... | |
616 | 621 |
.Except(_agent.GetEnumerable(), new PithosMonitor.LocalFileComparer()) |
617 | 622 |
.ToList(); |
618 | 623 |
|
619 |
if (distinctActions.Any()) |
|
620 |
{ |
|
621 |
StatusNotification.Notify(new Notification {Title = "Changes Detected",Message=String.Format("{0} files were modified",distinctActions.Count)}); |
|
622 |
} |
|
623 | 624 |
//Queue all the actions |
624 | 625 |
foreach (var message in distinctActions) |
625 | 626 |
{ |
... | ... | |
699 | 700 |
{ |
700 | 701 |
StatusKeeper.SetFileState(item.FullName, FileStatus.Conflict, FileOverlayStatus.Deleted); |
701 | 702 |
} |
702 |
StatusKeeper.SetPithosStatus(PithosStatus.HasConflicts);
|
|
703 |
UpdateStatus(PithosStatus.HasConflicts);
|
|
703 | 704 |
StatusNotification.NotifyConflicts(filesToDelete, String.Format("{0} local files are missing from Pithos, possibly because they were deleted",filesToDelete.Count)); |
704 | 705 |
} |
705 | 706 |
else |
... | ... | |
895 | 896 |
if (!Path.IsPathRooted(filePath)) |
896 | 897 |
throw new ArgumentException("The filePath must be rooted", "filePath"); |
897 | 898 |
Contract.EndContractBlock(); |
899 |
|
|
898 | 900 |
|
899 | 901 |
var localPath = Interfaces.FileInfoExtensions.GetProperFilePathCapitalization(filePath); |
900 | 902 |
var relativeUrl = new Uri(cloudFile.Name, UriKind.Relative); |
... | ... | |
922 | 924 |
Directory.CreateDirectory(localPath); |
923 | 925 |
} |
924 | 926 |
else |
925 |
{ |
|
927 |
{
|
|
926 | 928 |
//Retrieve the hashmap from the server |
927 | 929 |
var serverHash = await client.GetHashMap(account, container, url); |
928 | 930 |
//If it's a small file |
... | ... | |
977 | 979 |
if (localHash==cloudHash) |
978 | 980 |
return; |
979 | 981 |
} |
982 |
StatusNotification.Notify(new CloudNotification { Data = cloudFile }); |
|
980 | 983 |
|
981 | 984 |
var fileAgent = GetFileAgent(accountInfo); |
982 | 985 |
//Calculate the relative file path for the new file |
... | ... | |
1044 | 1047 |
var upHash = upHashes[i]; |
1045 | 1048 |
if (!localHashes.ContainsKey(upHash)) |
1046 | 1049 |
{ |
1050 |
StatusNotification.Notify(new CloudNotification { Data = cloudFile }); |
|
1051 |
|
|
1047 | 1052 |
if (blockUpdater.UseOrphan(i, upHash)) |
1048 | 1053 |
{ |
1049 | 1054 |
Log.InfoFormat("[BLOCK GET] ORPHAN FOUND for {0} of {1} for {2}", i, upHashes.Length, localPath); |
... | ... | |
1086 | 1091 |
Contract.EndContractBlock(); |
1087 | 1092 |
|
1088 | 1093 |
try |
1089 |
{ |
|
1094 |
{
|
|
1090 | 1095 |
var accountInfo = action.AccountInfo; |
1091 | 1096 |
|
1092 | 1097 |
var fileInfo = action.LocalFile; |
Also available in: Unified diff