Revision c53aa229 trunk/Pithos.Core/Agents/WorkflowAgent.cs
b/trunk/Pithos.Core/Agents/WorkflowAgent.cs | ||
---|---|---|
8 | 8 |
using System.Text; |
9 | 9 |
using System.Threading.Tasks; |
10 | 10 |
using Pithos.Interfaces; |
11 |
using Pithos.Network; |
|
11 | 12 |
using log4net; |
12 | 13 |
|
13 | 14 |
namespace Pithos.Core.Agents |
... | ... | |
23 | 24 |
|
24 | 25 |
//We should avoid processing files stored in the Fragments folder |
25 | 26 |
//The Full path to the fragments folder is stored in FragmentsPath |
26 |
public string FragmentsPath { get; set; } |
|
27 |
//public string FragmentsPath { get; set; }
|
|
27 | 28 |
|
28 | 29 |
[Import] |
29 | 30 |
public NetworkAgent NetworkAgent { get; set; } |
... | ... | |
48 | 49 |
|
49 | 50 |
private Task<object> Process(WorkflowState state) |
50 | 51 |
{ |
52 |
var accountInfo = state.AccountInfo; |
|
51 | 53 |
using (log4net.ThreadContext.Stacks["Workflow"].Push("Process")) |
52 | 54 |
{ |
53 | 55 |
if (Log.IsDebugEnabled) Log.DebugFormat("State {0} {1} {2}", state.FileName,state.Status,state.TriggeringChange); |
... | ... | |
71 | 73 |
return CompletedTask<object>.Default; |
72 | 74 |
} |
73 | 75 |
var fileState = FileState.FindByFilePath(path); |
74 |
var blockHash = NetworkAgent.BlockHash; |
|
75 |
var blockSize = NetworkAgent.BlockSize; |
|
76 | 76 |
var info = new FileInfo(path); |
77 | 77 |
|
78 | 78 |
switch (state.Status) |
79 | 79 |
{ |
80 | 80 |
case FileStatus.Created: |
81 | 81 |
case FileStatus.Modified: |
82 |
NetworkAgent.Post(new CloudUploadAction(info, fileState, blockSize, blockHash)); |
|
82 |
NetworkAgent.Post(new CloudUploadAction(accountInfo,info, fileState, accountInfo.BlockSize, |
|
83 |
accountInfo.BlockHash)); |
|
83 | 84 |
break; |
84 | 85 |
case FileStatus.Deleted: |
85 |
string fileName = info.AsRelativeUrlTo(NetworkAgent.FileAgent.RootPath);
|
|
86 |
NetworkAgent.Post(new CloudDeleteAction(fileName, fileState)); |
|
86 |
string fileName = info.AsRelativeUrlTo(accountInfo.AccountPath);
|
|
87 |
NetworkAgent.Post(new CloudDeleteAction(accountInfo,fileName, fileState));
|
|
87 | 88 |
break; |
88 | 89 |
case FileStatus.Renamed: |
89 |
NetworkAgent.Post(new CloudMoveAction(CloudActionType.RenameCloud, state.OldFileName, |
|
90 |
NetworkAgent.Post(new CloudMoveAction(accountInfo,CloudActionType.RenameCloud, state.OldFileName,
|
|
90 | 91 |
state.OldPath, state.FileName, state.Path)); |
91 | 92 |
break; |
92 | 93 |
} |
... | ... | |
96 | 97 |
} |
97 | 98 |
|
98 | 99 |
|
99 |
|
|
100 |
public void RestartInterruptedFiles() |
|
100 |
//Starts interrupted files for a specific account |
|
101 |
public void RestartInterruptedFiles(AccountInfo accountInfo)
|
|
101 | 102 |
{ |
102 | 103 |
|
103 | 104 |
StatusNotification.NotifyChange("Restart processing interrupted files", TraceLevel.Verbose); |
... | ... | |
106 | 107 |
{ |
107 | 108 |
if (Log.IsDebugEnabled) |
108 | 109 |
Log.Debug("Starting interrupted files"); |
109 |
|
|
110 |
|
|
111 |
var fragmentsPath = Path.Combine(accountInfo.AccountPath, FolderConstants.FragmentsFolder) |
|
112 |
.ToLower(); |
|
113 |
|
|
114 |
|
|
110 | 115 |
var pendingEntries = from state in FileState.Queryable |
111 | 116 |
where state.FileStatus != FileStatus.Unchanged && |
112 |
!state.FilePath.StartsWith(FragmentsPath.ToLower()) && |
|
113 |
!state.FilePath.EndsWith(".ignore") |
|
117 |
!state.FilePath.StartsWith(fragmentsPath) && |
|
118 |
!state.FilePath.EndsWith(".ignore") && |
|
119 |
state.FilePath.StartsWith(accountInfo.AccountPath) |
|
114 | 120 |
select state; |
115 | 121 |
if (Log.IsDebugEnabled) |
116 | 122 |
Log.DebugFormat("Found {0} interrupted files",pendingEntries.Count()); |
117 | 123 |
|
118 | 124 |
var validEntries = from state in pendingEntries |
119 |
select new WorkflowState |
|
125 |
select new WorkflowState(accountInfo)
|
|
120 | 126 |
{ |
121 | 127 |
Path = state.FilePath.ToLower(), |
122 | 128 |
FileName = Path.GetFileName(state.FilePath).ToLower(), |
Also available in: Unified diff