Revision 1a3dfbfd

b/trunk/Pithos.Client.WPF/PithosAccount.cs
152 152
                using (var client = await listener.AcceptTcpClientAsync()
153 153
                                        .WithTimeout(TimeSpan.FromMinutes(5)))
154 154
                {
155

  
156 155
                    using (var stream = client.GetStream())
157 156
                    using (var reader=new StreamReader(stream))
158 157
                    {
159 158
                        var request = await reader.ReadLineAsync();
160
                        if (request == null)
159
                        //BUG
160
                        //TODO: Add proper warnings here if the content is empty, don't just throw an exception
161
                        //This may be a common occurence 
162

  
163
                        if (String.IsNullOrWhiteSpace(request))
161 164
                            throw new Exception("Nothing retrieved");
162 165
                        Log.InfoFormat("[RETRIEVE] Got Connection {0}", request);
163 166

  
b/trunk/Pithos.Core/Agents/NetworkAgent.cs
81 81

  
82 82
        private bool _firstPoll = true;
83 83
        private TaskCompletionSource<bool> _tcs;
84
        private ConcurrentDictionary<string,DateTime> _lastSeen=new ConcurrentDictionary<string, DateTime>();
84 85

  
85 86
        public void Start()
86 87
        {
......
678 679
            //Consider for deleteion only files modified before the PREVIOUS poll
679 680
            //A user may perform a file creation or rename at roughly the same time as a poll. In such a case
680 681
            //the new file will appear as deleted
681
            var previousPollTime = pollTime.Subtract(TimeSpan.FromMilliseconds(Settings.PollingInterval));
682
            var previousPollTime = pollTime.Subtract(TimeSpan.FromMilliseconds(Settings.PollingInterval));                       
682 683

  
684
            //Only consider files that are not being modified, ie they are in the Unchanged state            
683 685
            var deleteCandidates = FileState.Queryable.Where(state => 
684 686
                state.Modified <= previousPollTime
685
                && state.FilePath.StartsWith(accountInfo.AccountPath)
686
                && state.FileStatus != FileStatus.Conflict).ToList();
687
                && state.FilePath.StartsWith(accountInfo.AccountPath)                
688
                && state.FileStatus == FileStatus.Unchanged).ToList();
687 689

  
688
            //TODO: filesToDelete must take into account the Others container
690
            //TODO: filesToDelete must take into account the Others container            
689 691
            var filesToDelete = (from deleteCandidate in deleteCandidates 
690 692
                         let localFile = FileInfoExtensions.FromPath(deleteCandidate.FilePath) 
691 693
                         let relativeFilePath = localFile.AsRelativeTo(accountInfo.AccountPath) 
692
                         where !cloudFiles.Any(r => r.RelativeUrlToFilePath(accountInfo.UserName) == relativeFilePath ) 
694
                         let agentActions = _agent.GetEnumerable()
695
                         where 
696
                                 !_lastSeen.ContainsKey(localFile.FullName)
697
                         && !cloudFiles.Any(r => r.RelativeUrlToFilePath(accountInfo.UserName) == relativeFilePath ) 
693 698
                         //Exclude files enqueued for uploading
694 699
                         //Large files will not appear on the server for multiple polls. They must not be marked as deleted
695
                         && !_agent.GetEnumerable().Any(action => action.LocalFile.WithProperCapitalization().FullName == localFile.FullName)
700
                         && !agentActions.Any(action => action.LocalFile.WithProperCapitalization().FullName == localFile.FullName)
696 701
                         //Do NOT delete files modified since the previous poll
697 702
                                && localFile.LastAccessTime < previousPollTime
698 703
                         select localFile).ToList();
704
            
699 705

  
700 706
            //On the first run
701 707
            if (_firstPoll)
......
781 787
                    using (new SessionScope(FlushAction.Never))
782 788
                    {
783 789
                        var state =  StatusKeeper.GetStateByFilePath(localFile.FullName);
790
                        _lastSeen[localFile.FullName] = DateTime.Now;
784 791
                        //FileState.FindByFilePath(localFile.FullName);
785 792
                        //Common files should be checked on a per-case basis to detect differences, which is newer
786 793

  

Also available in: Unified diff