Revision 5ce54458 trunk/Pithos.Core/Agents/WorkflowAgent.cs
b/trunk/Pithos.Core/Agents/WorkflowAgent.cs | ||
---|---|---|
18 | 18 |
public IStatusNotification StatusNotification { get; set; } |
19 | 19 |
[Import] |
20 | 20 |
public IStatusKeeper StatusKeeper { get; set; } |
21 |
[Import] |
|
22 |
public IPithosWorkflow Workflow { get; set; } |
|
21 |
|
|
22 |
//We should avoid processing files stored in the Fragments folder |
|
23 |
//The Full path to the fragments folder is stored in FragmentsPath |
|
24 |
public string FragmentsPath { get; set; } |
|
23 | 25 |
|
24 | 26 |
[Import] |
25 | 27 |
public NetworkAgent NetworkAgent { get; set; } |
... | ... | |
57 | 59 |
|
58 | 60 |
public void RestartInterruptedFiles() |
59 | 61 |
{ |
62 |
|
|
60 | 63 |
StatusNotification.NotifyChange("Restart processing interrupted files", TraceLevel.Verbose); |
61 | 64 |
var interruptedStates = new[] { FileOverlayStatus.Unversioned, FileOverlayStatus.Modified }; |
62 |
var filesQuery = from state in FileState.Queryable |
|
63 |
where interruptedStates.Contains(state.OverlayStatus) |
|
65 |
|
|
66 |
var pendingEntries = (from state in FileState.Queryable |
|
67 |
where interruptedStates.Contains(state.OverlayStatus) && |
|
68 |
!state.FilePath.StartsWith(FragmentsPath) && |
|
69 |
!state.FilePath.EndsWith(".ignore") |
|
70 |
select state).ToList(); |
|
71 |
var staleEntries = from state in pendingEntries |
|
72 |
where !File.Exists(state.FilePath) |
|
73 |
select state; |
|
74 |
var staleKeys = staleEntries.Select(state=>state.Id); |
|
75 |
FileState.DeleteAll(staleKeys); |
|
76 |
|
|
77 |
var validEntries = from state in pendingEntries.Except(staleEntries) |
|
78 |
where File.Exists(state.FilePath) |
|
64 | 79 |
select new WorkflowState |
65 | 80 |
{ |
66 | 81 |
Path = state.FilePath.ToLower(), |
... | ... | |
73 | 88 |
WatcherChangeTypes.Created : |
74 | 89 |
WatcherChangeTypes.Changed |
75 | 90 |
}; |
76 |
_agent.AddFromEnumerable(filesQuery); |
|
77 | 91 |
|
78 |
} |
|
92 |
_agent.AddFromEnumerable(validEntries); |
|
93 |
|
|
79 | 94 |
|
95 |
} |
|
80 | 96 |
|
81 | 97 |
private void Process(WorkflowState state) |
82 | 98 |
{ |
Also available in: Unified diff