60 |
60 |
|
61 |
61 |
//A separate agent is used to execute delete actions immediatelly;
|
62 |
62 |
private Agent<CloudDeleteAction> _deleteAgent;
|
63 |
|
ConcurrentDictionary<string,DateTime> _deletedFiles=new ConcurrentDictionary<string, DateTime>();
|
|
63 |
readonly ConcurrentDictionary<string,DateTime> _deletedFiles=new ConcurrentDictionary<string, DateTime>();
|
64 |
64 |
|
65 |
65 |
[System.ComponentModel.Composition.Import]
|
66 |
66 |
public IStatusKeeper StatusKeeper { get; set; }
|
... | ... | |
120 |
120 |
try
|
121 |
121 |
{
|
122 |
122 |
|
123 |
|
switch (action.Action)
|
|
123 |
if (action.Action == CloudActionType.DeleteCloud)
|
124 |
124 |
{
|
125 |
|
case CloudActionType.UploadUnconditional:
|
126 |
|
//Abort if the file was deleted before we reached this point
|
127 |
|
if (!IsDeletedFile(action))
|
|
125 |
//Redirect deletes to the delete agent
|
|
126 |
_deleteAgent.Post((CloudDeleteAction)action);
|
|
127 |
}
|
|
128 |
if (IsDeletedFile(action))
|
|
129 |
{
|
|
130 |
//Clear the status of already deleted files to avoid reprocessing
|
|
131 |
this.StatusKeeper.ClearFileStatus(action.LocalFile.FullName);
|
|
132 |
}
|
|
133 |
else
|
|
134 |
{
|
|
135 |
switch (action.Action)
|
|
136 |
{
|
|
137 |
case CloudActionType.UploadUnconditional:
|
|
138 |
//Abort if the file was deleted before we reached this point
|
128 |
139 |
await UploadCloudFile(action);
|
129 |
|
break;
|
130 |
|
case CloudActionType.DownloadUnconditional:
|
131 |
|
if (!IsDeletedFile(action))
|
|
140 |
break;
|
|
141 |
case CloudActionType.DownloadUnconditional:
|
132 |
142 |
await DownloadCloudFile(accountInfo, cloudFile, downloadPath);
|
133 |
|
break;
|
134 |
|
case CloudActionType.DeleteCloud:
|
135 |
|
//Redirect deletes to the delete agent
|
136 |
|
_deleteAgent.Post((CloudDeleteAction)action);
|
137 |
|
break;
|
138 |
|
case CloudActionType.RenameCloud:
|
139 |
|
var moveAction = (CloudMoveAction)action;
|
140 |
|
if (!IsDeletedFile(action))
|
|
143 |
break;
|
|
144 |
case CloudActionType.RenameCloud:
|
|
145 |
var moveAction = (CloudMoveAction) action;
|
141 |
146 |
RenameCloudFile(accountInfo, moveAction);
|
142 |
|
break;
|
143 |
|
case CloudActionType.MustSynch:
|
144 |
|
if (!File.Exists(downloadPath) && !Directory.Exists(downloadPath))
|
145 |
|
{
|
146 |
|
if (!IsDeletedFile(action))
|
|
147 |
break;
|
|
148 |
case CloudActionType.MustSynch:
|
|
149 |
if (!File.Exists(downloadPath) && !Directory.Exists(downloadPath))
|
|
150 |
{
|
147 |
151 |
await DownloadCloudFile(accountInfo, cloudFile, downloadPath);
|
148 |
|
}
|
149 |
|
else
|
150 |
|
{
|
151 |
|
if (!IsDeletedFile(action))
|
|
152 |
}
|
|
153 |
else
|
|
154 |
{
|
152 |
155 |
await SyncFiles(accountInfo, action);
|
153 |
|
}
|
154 |
|
break;
|
|
156 |
}
|
|
157 |
break;
|
|
158 |
}
|
155 |
159 |
}
|
156 |
160 |
Log.InfoFormat("[ACTION] End Processing {0}:{1}->{2}", action.Action, action.LocalFile,
|
157 |
161 |
action.CloudFile.Name);
|