[Import]\r
private IStatusKeeper StatusKeeper { get; set; }\r
\r
+ [Import]\r
+ private IPithosSettings Settings { get; set; }\r
\r
public IStatusNotification StatusNotification { get; set; }\r
\r
\r
localTreeHash = Signature.CalculateTreeHashAsync(filePath,\r
accountInfo.BlockSize,\r
- accountInfo.BlockHash, 1,cancellationToken,progress);\r
+ accountInfo.BlockHash, Settings.HashingParallelism,cancellationToken,progress);\r
}\r
\r
var localPath = FileInfoExtensions.GetProperFilePathCapitalization(filePath);\r
StatusNotification.Notify(new StatusNotification(String.Format("Hashing for Download {0} of {1}", d, fileName))));\r
\r
//TODO: Should pass cancellation token here\r
- var treeHash = localTreeHash ?? Signature.CalculateTreeHashAsync(localPath, (int)serverHash.BlockSize, serverHash.BlockHash, 2,cancellationToken,progress);\r
+ var treeHash = localTreeHash ?? Signature.CalculateTreeHashAsync(localPath, (int)serverHash.BlockSize, serverHash.BlockHash, Settings.HashingParallelism,cancellationToken,progress);\r
\r
//And compare it with the server's hash\r
var upHashes = serverHash.GetHashesAsStrings();\r
[Import]\r
private IStatusKeeper StatusKeeper { get; set; }\r
\r
+ [Import]\r
+ private IPithosSettings Settings { get; set; }\r
+\r
public IStatusNotification StatusNotification { get; set; }\r
\r
\r
{\r
localTreeHash = Signature.CalculateTreeHashAsync(fileInfo.FullName,\r
action.AccountInfo.BlockSize,\r
- action.AccountInfo.BlockHash, 1,cancellationToken,progress);\r
+ action.AccountInfo.BlockHash, Settings.HashingParallelism,cancellationToken,progress);\r
}\r
\r
if (fileInfo.Extension.Equals("ignore", StringComparison.InvariantCultureIgnoreCase))\r
\r
await UnpauseEvent.WaitAsync().ConfigureAwait(false);\r
\r
- if (fileInfo is DirectoryInfo)\r
+ fileInfo.Refresh();\r
+ //Does the file still exist or was it deleted/renamed?\r
+ if (fileInfo.Exists)\r
{\r
- //If the directory doesn't exist the Hash property will be empty\r
- if (String.IsNullOrWhiteSpace(cloudInfo.X_Object_Hash))\r
- //Go on and create the directory\r
- await client.PutObject(account, cloudFile.Container, cloudFile.Name, fullFileName,\r
- String.Empty, "application/directory");\r
- //If the upload is in response to a Folder create with Selective Sync enabled\r
- if (action.IsCreation)\r
+ if (fileInfo is DirectoryInfo)\r
{\r
- //Add the folder to the Selected URls\r
- var selectiveUri = new Uri(client.RootAddressUri, cloudFile.Uri);\r
- Selectives.AddUri(accountInfo, selectiveUri); \r
- Selectives.Save(accountInfo);\r
+ //If the directory doesn't exist the Hash property will be empty\r
+ if (String.IsNullOrWhiteSpace(cloudInfo.X_Object_Hash))\r
+ //Go on and create the directory\r
+ await\r
+ client.PutObject(account, cloudFile.Container, cloudFile.Name, fullFileName,\r
+ String.Empty, "application/directory");\r
+ //If the upload is in response to a Folder create with Selective Sync enabled\r
+ if (action.IsCreation)\r
+ {\r
+ //Add the folder to the Selected URls\r
+ var selectiveUri = new Uri(client.RootAddressUri, cloudFile.Uri);\r
+ Selectives.AddUri(accountInfo, selectiveUri);\r
+ Selectives.Save(accountInfo);\r
+ }\r
}\r
- }\r
- else\r
- {\r
+ else\r
+ {\r
\r
- var cloudHash = cloudInfo.X_Object_Hash.ToLower();\r
+ var cloudHash = cloudInfo.X_Object_Hash.ToLower();\r
\r
- string topHash;\r
- TreeHash treeHash;\r
- using(StatusNotification.GetNotifier("Hashing {0} for Upload", "Finished hashing {0}",fileInfo.Name))\r
- {\r
- treeHash = localTreeHash??action.TreeHash.Value;\r
- topHash = treeHash.TopHash.ToHashString();\r
- }\r
+ string topHash;\r
+ TreeHash treeHash;\r
+ using (\r
+ StatusNotification.GetNotifier("Hashing {0} for Upload", "Finished hashing {0}",\r
+ fileInfo.Name))\r
+ {\r
+ treeHash = localTreeHash ?? action.TreeHash.Value;\r
+ topHash = treeHash.TopHash.ToHashString();\r
+ }\r
\r
\r
\r
- //If the file hashes match, abort the upload\r
- if (cloudInfo != ObjectInfo.Empty && (topHash == cloudHash ))\r
- {\r
- //but store any metadata changes \r
- StatusKeeper.StoreInfo(fullFileName, cloudInfo);\r
- Log.InfoFormat("Skip upload of {0}, hashes match", fullFileName);\r
- return;\r
- }\r
+ //If the file hashes match, abort the upload\r
+ if (cloudInfo != ObjectInfo.Empty && (topHash == cloudHash))\r
+ {\r
+ //but store any metadata changes \r
+ StatusKeeper.StoreInfo(fullFileName, cloudInfo);\r
+ Log.InfoFormat("Skip upload of {0}, hashes match", fullFileName);\r
+ return;\r
+ }\r
+\r
\r
+ //Mark the file as modified while we upload it\r
+ await\r
+ StatusKeeper.SetFileOverlayStatus(fullFileName, FileOverlayStatus.Modified).\r
+ ConfigureAwait(false);\r
+ //And then upload it\r
\r
- //Mark the file as modified while we upload it\r
- await StatusKeeper.SetFileOverlayStatus(fullFileName, FileOverlayStatus.Modified).ConfigureAwait(false);\r
- //And then upload it\r
+ //Upload even small files using the Hashmap. The server may already contain\r
+ //the relevant block \r
\r
- //Upload even small files using the Hashmap. The server may already contain\r
- //the relevant block \r
\r
\r
+ await\r
+ UploadWithHashMap(accountInfo, cloudFile, fileInfo as FileInfo, cloudFile.Name,\r
+ treeHash, cancellationToken).ConfigureAwait(false);\r
+ }\r
\r
- await UploadWithHashMap(accountInfo, cloudFile, fileInfo as FileInfo, cloudFile.Name, treeHash, cancellationToken).ConfigureAwait(false);\r
+ var currentInfo = client.GetObjectInfo(cloudFile.Account, cloudFile.Container,\r
+ cloudFile.Name);\r
+ //If there is no stored ObjectID in the file state, add it\r
+ if (action.FileState == null || action.FileState.ObjectID == null)\r
+ {\r
+ StatusKeeper.StoreInfo(fullFileName, currentInfo);\r
+ }\r
+ else\r
+ //If everything succeeds, change the file and overlay status to normal\r
+ StatusKeeper.SetFileState(fullFileName, FileStatus.Unchanged,\r
+ FileOverlayStatus.Normal, "");\r
}\r
- var currentInfo=client.GetObjectInfo(cloudFile.Account, cloudFile.Container, cloudFile.Name);\r
- //If there is no stored ObjectID in the file state, add it\r
- if (action.FileState == null || action.FileState.ObjectID == null)\r
+ else\r
{\r
- StatusKeeper.StoreInfo(fullFileName,currentInfo);\r
+ StatusKeeper.ClearFileStatus(fullFileName);\r
}\r
- else \r
- //If everything succeeds, change the file and overlay status to normal\r
- StatusKeeper.SetFileState(fullFileName, FileStatus.Unchanged, FileOverlayStatus.Normal, "");\r
}\r
catch (WebException exc)\r
{\r