Revision 9c6d3193

b/trunk/Pithos.Client.WPF/Shell/ShellViewModel.cs
659 659

  
660 660
		}
661 661

  
662
	    public void NotifyConflicts(IEnumerable<FileSystemInfo> conflictFiles, string message)
663
	    {
664
            if (conflictFiles == null)
665
                return;
666
            if (!conflictFiles.Any())
667
                return;
668
            //TODO: Create a more specific message. For now, just show a warning
669
            NotifyForFiles(conflictFiles,message,TraceLevel.Warning);
670

  
671
	    }
672

  
673
	    public void NotifyForFiles(IEnumerable<FileSystemInfo> files, string message,TraceLevel level=TraceLevel.Info)
674
	    {
675
            if (files == null)
676
                return;
677
            if (!files.Any())
678
                return;
679

  
680
            StatusMessage = message;
681

  
682
            _events.Publish(new Notification { Title = "Pithos", Message = message, Level = level});
683
        }
684

  
662 685

  
663
		public void RemoveMonitor(string accountName)
686
	    public void RemoveMonitor(string accountName)
664 687
		{
665 688
			if (String.IsNullOrWhiteSpace(accountName))
666 689
				return;
b/trunk/Pithos.Core/Agents/NetworkAgent.cs
627 627
                throw new ArgumentNullException("cloudFiles");
628 628
            Contract.EndContractBlock();
629 629

  
630
            if (_firstPoll) return;
631
            //TODO: Do I need the "Modified" check if I'm not going to delete files that
632
            //were not found on the server on the first run?
633
            //TODO: Files that were not found on the server on the first run should be marked IN CONFLICT
634
            var deleteCandidates = from state in FileState.Queryable
635
                                   where state.Modified <= pollTime && state.FilePath.StartsWith(accountInfo.AccountPath)
636
                                   select state;
637

  
638
            foreach (var deleteCandidate in deleteCandidates)
630
            //Check the Modified date to ensure that were just created and haven't been uploaded yet
631
            //NOTE: The NHibernate LINQ provider doesn't support custom functions so we need to break the query 
632
            //in two steps
633
            //NOTE: DON'T return files that are already in conflict. The first poll would mark them as 
634
            //"In Conflict" but subsequent polls would delete them
635
            var deleteCandidates = (from state in FileState.Queryable
636
                                   where 
637
                                        state.Modified <= pollTime 
638
                                        && state.FilePath.StartsWith(accountInfo.AccountPath)
639
                                        && state.FileStatus != FileStatus.Conflict
640
                                   select state).ToList();
641

  
642
            var filesToDelete = (from deleteCandidate in deleteCandidates 
643
                         let localFile = FileInfoExtensions.FromPath(deleteCandidate.FilePath) 
644
                         let relativeFilePath = localFile.AsRelativeTo(accountInfo.AccountPath) 
645
                         where !cloudFiles.Any(r => Path.Combine(r.Container, r.Name) == relativeFilePath) 
646
                         select localFile).ToList();
647

  
648
            //On the first run
649
            if (_firstPoll)
639 650
            {
640
                var localFile = FileInfoExtensions.FromPath(deleteCandidate.FilePath);
641
                var relativeFilePath=localFile.AsRelativeTo(accountInfo.AccountPath);
642
                if (!cloudFiles.Any(r => Path.Combine(r.Container, r.Name) == relativeFilePath))
651
                //Set the status of missing files to Conflict
652
                foreach (var item in filesToDelete)
643 653
                {
644
                    localFile.Delete();
645
                    StatusKeeper.ClearFileStatus(deleteCandidate.FilePath);
654
                    StatusKeeper.SetFileState(item.FullName, FileStatus.Conflict, FileOverlayStatus.Deleted);
646 655
                }
656
                StatusNotification.NotifyConflicts(filesToDelete, String.Format("{0} local files are missing from Pithos, possibly because they were deleted",filesToDelete.Count));
647 657
            }
658
            else
659
            {
660
                foreach (var item in filesToDelete)
661
                {
662
                    item.Delete();
663
                    StatusKeeper.ClearFileStatus(item.FullName);
664
                }
665
                StatusNotification.NotifyForFiles(filesToDelete, String.Format("{0} files were deleted",filesToDelete.Count),TraceLevel.Info);
666
            }
667

  
648 668
        }
649 669

  
650 670
        private static void CreateContainerFolders(AccountInfo accountInfo, IEnumerable<ContainerInfo> containers)
b/trunk/Pithos.Core/IPithosWorkflow.cs
20 20
        Created,
21 21
        Modified,
22 22
        Renamed,
23
        Deleted
23
        Deleted,
24
        Conflict
24 25
    }
25 26
}
b/trunk/Pithos.Core/PithosMonitor.cs
570 570
        void NotifyChange(string status,TraceLevel level=TraceLevel.Info);
571 571
        void NotifyChangedFile(string filePath);
572 572
        void NotifyAccount(AccountInfo policy);
573
        void NotifyConflicts(IEnumerable<FileSystemInfo> conflictFiles, string message);
574
        void NotifyForFiles(IEnumerable<FileSystemInfo> files, string message,TraceLevel level);
573 575
    }
574 576
}

Also available in: Unified diff