Revision 5750d7cc trunk/Pithos.Core/Agents/NetworkAgent.cs
b/trunk/Pithos.Core/Agents/NetworkAgent.cs | ||
---|---|---|
310 | 310 |
Log.Info("Scheduled"); |
311 | 311 |
var client=new CloudFilesClient(accountInfo); |
312 | 312 |
|
313 |
var containers = client.ListContainers(accountInfo.UserName); |
|
314 |
|
|
315 |
CreateContainerFolders(accountInfo, containers); |
|
316 |
|
|
317 |
|
|
313 | 318 |
//Get the list of server objects changed since the last check |
314 | 319 |
var listObjects = Task<IList<ObjectInfo>>.Factory.StartNew(() => |
315 | 320 |
client.ListObjects(accountInfo.UserName, FolderConstants.PithosContainer, since)); |
... | ... | |
396 | 401 |
} |
397 | 402 |
} |
398 | 403 |
|
404 |
private static void CreateContainerFolders(AccountInfo accountInfo, IList<ContainerInfo> containers) |
|
405 |
{ |
|
406 |
var containerPaths = from container in containers |
|
407 |
let containerPath = Path.Combine(accountInfo.AccountPath, container.Name) |
|
408 |
where container.Name != FolderConstants.TrashContainer && !Directory.Exists(containerPath) |
|
409 |
select containerPath; |
|
410 |
|
|
411 |
foreach (var path in containerPaths) |
|
412 |
{ |
|
413 |
Directory.CreateDirectory(path); |
|
414 |
} |
|
415 |
} |
|
416 |
|
|
399 | 417 |
//Creates an appropriate action for each server file |
400 | 418 |
private IEnumerable<CloudAction> ObjectsToActions(AccountInfo accountInfo,IEnumerable<ObjectInfo> remote) |
401 | 419 |
{ |
... | ... | |
851 | 869 |
|
852 | 870 |
//Upload even small files using the Hashmap. The server may already containt |
853 | 871 |
//the relevant folder |
854 |
/* |
|
855 |
if (fileInfo.Length > accountInfo.BlockSize ) |
|
856 |
{ |
|
857 |
*/ |
|
858 |
//To upload using a hashmap |
|
859 |
//First, calculate the tree hash |
|
860 |
var treeHash = Signature.CalculateTreeHashAsync(fileInfo.FullName, accountInfo.BlockSize, |
|
861 |
accountInfo.BlockHash); |
|
862 |
yield return treeHash; |
|
872 |
|
|
873 |
//First, calculate the tree hash |
|
874 |
var treeHash = Signature.CalculateTreeHashAsync(fileInfo.FullName, accountInfo.BlockSize, |
|
875 |
accountInfo.BlockHash); |
|
876 |
yield return treeHash; |
|
863 | 877 |
|
864 |
yield return Task.Factory.Iterate(UploadWithHashMap(accountInfo,cloudFile,fileInfo,url,treeHash)); |
|
865 |
|
|
866 |
/* |
|
867 |
} |
|
868 |
else |
|
869 |
{ |
|
870 |
//Otherwise do a regular PUT |
|
871 |
yield return client.PutObject(account, container, url, fullFileName, hash); |
|
872 |
} |
|
873 |
*/ |
|
878 |
yield return Task.Factory.Iterate(UploadWithHashMap(accountInfo,cloudFile,fileInfo,url,treeHash)); |
|
879 |
|
|
874 | 880 |
//If everything succeeds, change the file and overlay status to normal |
875 | 881 |
this.StatusKeeper.SetFileState(fullFileName, FileStatus.Unchanged, FileOverlayStatus.Normal); |
876 | 882 |
} |
Also available in: Unified diff