Revision cfed7823 trunk/Pithos.Core/Agents/FileAgent.cs
b/trunk/Pithos.Core/Agents/FileAgent.cs | ||
---|---|---|
27 | 27 |
|
28 | 28 |
public string RootPath { get; private set; } |
29 | 29 |
|
30 |
|
|
30 | 31 |
public void Start(string rootPath) |
31 | 32 |
{ |
33 |
if (String.IsNullOrWhiteSpace(rootPath)) |
|
34 |
throw new ArgumentNullException("rootPath"); |
|
35 |
if (!Path.IsPathRooted(rootPath)) |
|
36 |
throw new ArgumentException("rootPath must be an absolute path","rootPath"); |
|
37 |
Contract.EndContractBlock(); |
|
38 |
|
|
32 | 39 |
RootPath = rootPath; |
33 | 40 |
_watcher = new FileSystemWatcher(rootPath); |
41 |
_watcher.IncludeSubdirectories = true; |
|
34 | 42 |
_watcher.Changed += OnFileEvent; |
35 | 43 |
_watcher.Created += OnFileEvent; |
36 | 44 |
_watcher.Deleted += OnFileEvent; |
... | ... | |
55 | 63 |
|
56 | 64 |
private Task<object> Process(WorkflowState state) |
57 | 65 |
{ |
66 |
if (state==null) |
|
67 |
throw new ArgumentNullException("state"); |
|
68 |
Contract.EndContractBlock(); |
|
69 |
|
|
58 | 70 |
Debug.Assert(!Ignore(state.Path)); |
59 | 71 |
|
60 | 72 |
var networkState = NetworkGate.GetNetworkState(state.Path); |
... | ... | |
116 | 128 |
|
117 | 129 |
public void Post(WorkflowState workflowState) |
118 | 130 |
{ |
131 |
if (workflowState == null) |
|
132 |
throw new ArgumentNullException("workflowState"); |
|
133 |
Contract.EndContractBlock(); |
|
134 |
|
|
119 | 135 |
_agent.Post(workflowState); |
120 | 136 |
} |
121 | 137 |
|
... | ... | |
131 | 147 |
} |
132 | 148 |
_watcher = null; |
133 | 149 |
|
134 |
_agent.Stop(); |
|
150 |
if (_agent!=null) |
|
151 |
_agent.Stop(); |
|
135 | 152 |
} |
136 | 153 |
|
137 | 154 |
// Enumerate all files in the Pithos directory except those in the Fragment folder |
... | ... | |
217 | 234 |
|
218 | 235 |
private WorkflowState UpdateFileStatus(WorkflowState state) |
219 | 236 |
{ |
220 |
Debug.Assert(!state.Path.Contains("fragments")); |
|
221 |
Debug.Assert(!state.Path.EndsWith(".ignore", StringComparison.InvariantCultureIgnoreCase)); |
|
237 |
if (state==null) |
|
238 |
throw new ArgumentNullException("state"); |
|
239 |
if (String.IsNullOrWhiteSpace(state.Path)) |
|
240 |
throw new ArgumentException("The state's Path can't be empty","state"); |
|
241 |
Contract.EndContractBlock(); |
|
222 | 242 |
|
223 |
string path = state.Path;
|
|
224 |
FileStatus status = _statusDict[state.TriggeringChange];
|
|
243 |
var path = state.Path;
|
|
244 |
var status = _statusDict[state.TriggeringChange];
|
|
225 | 245 |
var oldStatus = Workflow.StatusKeeper.GetFileStatus(path); |
226 | 246 |
if (status == oldStatus) |
227 | 247 |
{ |
... | ... | |
238 | 258 |
|
239 | 259 |
private WorkflowState UpdateOverlayStatus(WorkflowState state) |
240 | 260 |
{ |
261 |
if (state==null) |
|
262 |
throw new ArgumentNullException("state"); |
|
263 |
Contract.EndContractBlock(); |
|
264 |
|
|
241 | 265 |
if (state.Skip) |
242 | 266 |
return state; |
243 | 267 |
|
... | ... | |
248 | 272 |
this.StatusKeeper.SetFileOverlayStatus(state.Path, FileOverlayStatus.Modified); |
249 | 273 |
break; |
250 | 274 |
case FileStatus.Deleted: |
251 |
//this.StatusKeeper.RemoveFileOverlayStatus(state.Path);
|
|
275 |
//this.StatusAgent.RemoveFileOverlayStatus(state.Path);
|
|
252 | 276 |
break; |
253 | 277 |
case FileStatus.Renamed: |
254 |
this.StatusKeeper.RemoveFileOverlayStatus(state.OldPath);
|
|
278 |
this.StatusKeeper.ClearFileStatus(state.OldPath);
|
|
255 | 279 |
this.StatusKeeper.SetFileOverlayStatus(state.Path, FileOverlayStatus.Modified); |
256 | 280 |
break; |
257 | 281 |
case FileStatus.Unchanged: |
... | ... | |
319 | 343 |
Contract.EndContractBlock(); |
320 | 344 |
|
321 | 345 |
var absolutePath = Path.Combine(RootPath, relativePath); |
322 |
Debug.Assert(File.Exists(absolutePath),String.Format("Path {0} doesn't exist",absolutePath)); |
|
346 |
// Debug.Assert(File.Exists(absolutePath),String.Format("Path {0} doesn't exist",absolutePath));
|
|
323 | 347 |
|
324 | 348 |
return new FileInfo(absolutePath); |
325 | 349 |
|
Also available in: Unified diff