Revision 79f92570 trunk/Pithos.Core/Agents/FileAgent.cs

b/trunk/Pithos.Core/Agents/FileAgent.cs
73 73
        private AccountInfo AccountInfo { get; set; }
74 74

  
75 75
        internal string RootPath { get;  set; }
76
        
77
        private FileEventIdleBatch _eventIdleBatch;
78

  
79
        public FileAgent(int idleTimeout)
80
        {            
81
            _eventIdleBatch=new FileEventIdleBatch(idleTimeout,ProcessBatchedEvents);
82
        }
76 83

  
84
        private void ProcessBatchedEvents(Dictionary<string, FileSystemEventArgs[]> fileEvents)
85
        {
86
            StatusNotification.SetPithosStatus(PithosStatus.LocalSyncing,String.Format("Uploading {0} files",fileEvents.Count));
87
            foreach (var fileEvent in fileEvents)
88
            {
89
                var filePath = fileEvent.Key;
90
                var changes = fileEvent.Value;
91
                
92
                if (Ignore(filePath)) continue;
93
                                
94
                foreach (var change in changes)
95
                {
96
                    if (change.ChangeType == WatcherChangeTypes.Renamed)
97
                    {
98
                        var rename = (RenamedEventArgs) change;
99
                        _agent.Post(new WorkflowState
100
                                        {
101
                                            AccountInfo = AccountInfo,
102
                                            OldPath = rename.OldFullPath,
103
                                            OldFileName = rename.OldName,
104
                                            Path = rename.FullPath,
105
                                            FileName = rename.Name,
106
                                            TriggeringChange = rename.ChangeType
107
                                        });
108
                    }
109
                    else
110
                        _agent.Post(new WorkflowState
111
                        {
112
                            AccountInfo = AccountInfo,
113
                            Path = change.FullPath,
114
                            FileName = change.Name,
115
                            TriggeringChange = change.ChangeType
116
                        });                        
117
                }
118
            }
119
            StatusNotification.SetPithosStatus(PithosStatus.LocalComplete);
120
        }
77 121

  
78 122
        public void Start(AccountInfo accountInfo,string rootPath)
79 123
        {
......
320 364
            var filePath = e.FullPath;
321 365
            if (Ignore(filePath)) 
322 366
                return;
323

  
324
            _agent.Post(new WorkflowState{AccountInfo=AccountInfo, Path = filePath, FileName = e.Name, TriggeringChange = e.ChangeType });
367
            _eventIdleBatch.Post(e);
325 368
        }
326 369

  
327 370

  
......
354 397
            if (Ignore(oldFullPath) || Ignore(fullPath))
355 398
                return;
356 399

  
357
            _agent.Post(new WorkflowState
358
            {
359
                AccountInfo=AccountInfo,
360
                OldPath = oldFullPath,
361
                OldFileName = e.OldName,
362
                Path = fullPath,
363
                FileName = e.Name,
364
                TriggeringChange = e.ChangeType
365
            });
400
            _eventIdleBatch.Post(e);
366 401
        }
367 402

  
368 403

  

Also available in: Unified diff