return;
if (!conflictFiles.Any())
return;
+
+ UpdateStatus();
//TODO: Create a more specific message. For now, just show a warning
NotifyForFiles(conflictFiles,message,TraceLevel.Warning);
_events.Publish(new Notification { Title = "Pithos", Message = message, Level = level});
}
+ public void Notify(Notification notification)
+ {
+ _events.Publish(notification);
+ }
+
public void RemoveMonitor(string accountName)
{
//The notifications should be moved to their own view/viewmodel pair
//and different templates should be used for different message types
//This will also allow the addition of extra functionality, eg. actions
- //to perform when clicking on a balloon
+ //
public void Handle(Notification notification)
{
+ UpdateStatus();
+
if (!Settings.ShowDesktopNotifications)
return;
BalloonIcon icon;
throw new ArgumentException("The action.AccountInfo is empty","action");
Contract.EndContractBlock();
+ StatusKeeper.SetPithosStatus(PithosStatus.Syncing);
var accountInfo = action.AccountInfo;
using (log4net.ThreadContext.Stacks["NETWORK"].Push("PROCESS"))
if (action.Action == CloudActionType.DeleteCloud)
{
//Redirect deletes to the delete agent
- _deleteAgent.Post((CloudDeleteAction)action);
+ _deleteAgent.Post((CloudDeleteAction)action);
}
if (IsDeletedFile(action))
{
await DownloadCloudFile(accountInfo, cloudFile, downloadPath);
break;
case CloudActionType.RenameCloud:
- var moveAction = (CloudMoveAction) action;
+ var moveAction = (CloudMoveAction)action;
RenameCloudFile(accountInfo, moveAction);
break;
case CloudActionType.MustSynch:
Log.ErrorFormat("{0} : {1} -> {2} failed because the directory was not found.\n Rescheduling a delete",
action.Action, action.LocalFile, action.CloudFile);
//Post a delete action for the missing file
- Post(new CloudDeleteAction(action));
+ Post(new CloudDeleteAction(action));
}
catch (FileNotFoundException)
{
action.Action, action.LocalFile, action.CloudFile, exc);
_agent.Post(action);
- }
+ }
+ finally
+ {
+ StatusKeeper.SetPithosStatus(PithosStatus.InSynch);
+ }
}
}
Contract.EndContractBlock();
StatusKeeper.SetFileOverlayStatus(downloadPath, FileOverlayStatus.Conflict);
+ StatusKeeper.SetPithosStatus(PithosStatus.HasConflicts);
var message = String.Format("Conflict detected for file {0}", downloadPath);
Log.Warn(message);
StatusNotification.NotifyChange(message, TraceLevel.Warning);
//Remote files are polled periodically. Any changes are processed
public async Task PollRemoteFiles(DateTime? since = null,bool repeat=true)
{
-
+ StatusNotification.Notify(new Notification{Title="Polling Pithos"});
+ StatusKeeper.SetPithosStatus(PithosStatus.Syncing);
using (log4net.ThreadContext.Stacks["Retrieve Remote"].Push("All accounts"))
{
throw new ArgumentException("The AccountInfo.AccountPath is empty","accountInfo");
Contract.EndContractBlock();
+ StatusNotification.Notify(new Notification{Title=String.Format("Polling {0}",accountInfo.UserName)});
+
using (log4net.ThreadContext.Stacks["Retrieve Remote"].Push(accountInfo.UserName))
{
Log.Info("Scheduled");
.Except(_agent.GetEnumerable(), new PithosMonitor.LocalFileComparer())
.ToList();
+ if (distinctActions.Any())
+ {
+ StatusNotification.Notify(new Notification {Title = "Changes Detected",Message=String.Format("{0} files were modified",distinctActions.Count)});
+ }
//Queue all the actions
foreach (var message in distinctActions)
{
{
StatusKeeper.SetFileState(item.FullName, FileStatus.Conflict, FileOverlayStatus.Deleted);
}
+ StatusKeeper.SetPithosStatus(PithosStatus.HasConflicts);
StatusNotification.NotifyConflicts(filesToDelete, String.Format("{0} local files are missing from Pithos, possibly because they were deleted",filesToDelete.Count));
}
else
--- /dev/null
+using System.Collections.Generic;\r
+using System.Diagnostics;\r
+using System.IO;\r
+using Pithos.Network;\r
+\r
+namespace Pithos.Core\r
+{\r
+ public interface IStatusNotification\r
+ { \r
+ void NotifyChange(string status,TraceLevel level=TraceLevel.Info);\r
+ void NotifyChangedFile(string filePath);\r
+ void NotifyAccount(AccountInfo policy);\r
+ void NotifyConflicts(IEnumerable<FileSystemInfo> conflictFiles, string message);\r
+ void NotifyForFiles(IEnumerable<FileSystemInfo> files, string message,TraceLevel level);\r
+ void Notify(Notification notification);\r
+ }\r
+\r
+ public class Notification\r
+ {\r
+ public TraceLevel Level { get; set; }\r
+ public string Title { get; set; }\r
+ public string Message { get; set; }\r
+\r
+ public Notification()\r
+ {\r
+ Level=TraceLevel.Info;\r
+ Title = "";\r
+ Message = "";\r
+ }\r
+ }\r
+\r
+ public class Notification<T>:Notification\r
+ {\r
+ public T Data { get; set; }\r
+ }\r
+\r
+ public class FilesNotification:Notification<IEnumerable<FileSystemInfo>>\r
+ { \r
+ }\r
+}
\ No newline at end of file