Revision 4f6d51d4 trunk/Pithos.Core/Agents/FileAgent.cs
b/trunk/Pithos.Core/Agents/FileAgent.cs | ||
---|---|---|
75 | 75 |
throw new ArgumentNullException("state"); |
76 | 76 |
Contract.EndContractBlock(); |
77 | 77 |
|
78 |
Debug.Assert(!Ignore(state.Path)); |
|
78 |
if (Ignore(state.Path)) |
|
79 |
return CompletedTask<object>.Default; |
|
79 | 80 |
|
80 | 81 |
var networkState = NetworkGate.GetNetworkState(state.Path); |
81 | 82 |
//Skip if the file is already being downloaded or uploaded and |
... | ... | |
192 | 193 |
|
193 | 194 |
private bool Ignore(string filePath) |
194 | 195 |
{ |
196 |
var pithosPath = Path.Combine(RootPath, "pithos"); |
|
197 |
if (pithosPath.Equals(filePath, StringComparison.InvariantCultureIgnoreCase)) |
|
198 |
return true; |
|
195 | 199 |
if (filePath.StartsWith(CachePath)) |
196 | 200 |
return true; |
197 | 201 |
if (_ignoreFiles.ContainsKey(filePath.ToLower())) |
... | ... | |
206 | 210 |
var filePath = e.FullPath; |
207 | 211 |
if (Ignore(filePath)) |
208 | 212 |
return; |
209 |
if (Directory.Exists(filePath)) |
|
210 |
return; |
|
213 |
/* if (Directory.Exists(filePath))
|
|
214 |
return; */
|
|
211 | 215 |
_agent.Post(new WorkflowState{AccountInfo=AccountInfo, Path = filePath, FileName = e.Name, TriggeringChange = e.ChangeType }); |
212 | 216 |
} |
213 | 217 |
|
... | ... | |
344 | 348 |
return false; |
345 | 349 |
} |
346 | 350 |
|
347 |
public FileInfo GetFileInfo(string relativePath) |
|
351 |
public FileSystemInfo GetFileInfo(string relativePath)
|
|
348 | 352 |
{ |
349 | 353 |
if (String.IsNullOrWhiteSpace(relativePath)) |
350 | 354 |
throw new ArgumentNullException("relativePath"); |
... | ... | |
354 | 358 |
Contract.EndContractBlock(); |
355 | 359 |
|
356 | 360 |
var absolutePath = Path.Combine(RootPath, relativePath); |
357 |
// Debug.Assert(File.Exists(absolutePath),String.Format("Path {0} doesn't exist",absolutePath)); |
|
358 | 361 |
|
359 |
return new FileInfo(absolutePath); |
|
362 |
if (Directory.Exists(absolutePath)) |
|
363 |
return new DirectoryInfo(absolutePath); |
|
364 |
else |
|
365 |
return new FileInfo(absolutePath); |
|
360 | 366 |
|
361 | 367 |
} |
362 | 368 |
|
363 | 369 |
public void Delete(string relativePath) |
364 | 370 |
{ |
365 |
var absolutePath = Path.Combine(RootPath, relativePath); |
|
371 |
var absolutePath = Path.Combine(RootPath, relativePath).ToLower();
|
|
366 | 372 |
if (File.Exists(absolutePath)) |
367 |
{ |
|
368 |
File.Delete(absolutePath); |
|
369 |
_ignoreFiles[absolutePath.ToLower()] = absolutePath.ToLower(); |
|
373 |
{ |
|
374 |
try |
|
375 |
{ |
|
376 |
File.Delete(absolutePath); |
|
377 |
} |
|
378 |
//The file may have been deleted by another thread. Just ignore the relevant exception |
|
379 |
catch (FileNotFoundException) { } |
|
380 |
} |
|
381 |
else if (Directory.Exists(absolutePath)) |
|
382 |
{ |
|
383 |
try |
|
384 |
{ |
|
385 |
Directory.Delete(absolutePath, true); |
|
386 |
} |
|
387 |
//The directory may have been deleted by another thread. Just ignore the relevant exception |
|
388 |
catch (DirectoryNotFoundException){} |
|
370 | 389 |
} |
390 |
|
|
391 |
//_ignoreFiles[absolutePath] = absolutePath; |
|
371 | 392 |
StatusKeeper.ClearFileStatus(absolutePath); |
372 | 393 |
} |
373 | 394 |
} |
Also available in: Unified diff