Revision 78ebfd2d trunk/Pithos.Core/Agents/FileAgent.cs

b/trunk/Pithos.Core/Agents/FileAgent.cs
19 19
    {
20 20
        Agent<WorkflowState> _agent;
21 21
        private FileSystemWatcher _watcher;
22
        private FileSystemWatcherAdapter _adapter;
22 23

  
23 24
        //[Import]
24 25
        public IStatusKeeper StatusKeeper { get; set; }
......
45 46

  
46 47
            AccountInfo = accountInfo;
47 48
            RootPath = rootPath;
48
            _watcher = new FileSystemWatcher(rootPath);
49
            _watcher.IncludeSubdirectories = true;            
50
            _watcher.Changed += OnFileEvent;
51
            _watcher.Created += OnFileEvent;
52
            _watcher.Deleted += OnFileEvent;
53
            _watcher.Renamed += OnRenameEvent;
49
            _watcher = new FileSystemWatcher(rootPath) {IncludeSubdirectories = true};
50
            _adapter = new FileSystemWatcherAdapter(_watcher);
51

  
52
            _adapter.Changed += OnFileEvent;
53
            _adapter.Created += OnFileEvent;
54
            _adapter.Deleted += OnFileEvent;
55
            _adapter.Renamed += OnRenameEvent;
56
            _adapter.Moved += OnMoveEvent;
54 57
            _watcher.EnableRaisingEvents = true;
55 58

  
56 59

  
......
234 237
            });
235 238
        }
236 239

  
240
        //Post a Change message for renames containing the old and new names
241
        void OnMoveEvent(object sender, MovedEventArgs e)
242
        {
243
            var oldFullPath = e.OldFullPath;
244
            var fullPath = e.FullPath;
245
            if (Ignore(oldFullPath) || Ignore(fullPath))
246
                return;
247

  
248
            _agent.Post(new WorkflowState
249
            {
250
                AccountInfo=AccountInfo,
251
                OldPath = oldFullPath,
252
                OldFileName = e.OldName,
253
                Path = fullPath,
254
                FileName = e.Name,
255
                TriggeringChange = e.ChangeType
256
            });
257
        }
258

  
237 259

  
238 260

  
239 261
        private Dictionary<WatcherChangeTypes, FileStatus> _statusDict = new Dictionary<WatcherChangeTypes, FileStatus>

Also available in: Unified diff