var localInfo = FileInfoExtensions.FromPath(localFilePath);\r
\r
\r
+ var isUnselectedRootFolder = agent.IsUnselectedRootFolder(tuple.FilePath);\r
+\r
+ //Unselected root folders that have not yet been uploaded should be uploaded and added to the \r
+ //selective folders\r
+\r
+ if (!Selectives.IsSelected(accountInfo, localFilePath) && !(isUnselectedRootFolder && tuple.ObjectInfo==null) ) \r
+ return;\r
+\r
// Local file unchanged? If both C and L are null, make sure it's because \r
//both the file is missing and the state checksum is not missing\r
- if (tuple.C == tuple.L && (localInfo.Exists || tuple.FileState==null))\r
+ if (tuple.C == tuple.L /*&& (localInfo.Exists || tuple.FileState == null)*/)\r
{\r
//No local changes\r
//Server unchanged?\r
else\r
{\r
//Different from server\r
- if (Selectives.IsSelected(accountInfo, localFilePath))\r
+ //Does the server file exist?\r
+ if (tuple.S == null)\r
{\r
- //Does the server file exist?\r
- if (tuple.S == null)\r
- {\r
- //Server file doesn't exist\r
- //deleteObjectFromLocal()\r
- StatusKeeper.SetFileState(localFilePath, FileStatus.Deleted,\r
- FileOverlayStatus.Deleted, "");\r
- agent.Delete(localFilePath);\r
- //updateRecord(Remove C, L)\r
- StatusKeeper.ClearFileStatus(localFilePath);\r
- }\r
- else\r
- {\r
- //Server file exists\r
- //downloadServerObject() // Result: L = S\r
- //If the file has moved on the server, move it locally before downloading\r
- var targetPath=MoveForServerMove(accountInfo,tuple);\r
-\r
- StatusKeeper.SetFileState(targetPath, FileStatus.Modified,\r
- FileOverlayStatus.Modified, "");\r
- NetworkAgent.Downloader.DownloadCloudFile(accountInfo,\r
- tuple.ObjectInfo,\r
- targetPath,tuple.Merkle, token).Wait(token);\r
- //updateRecord( L = S )\r
- StatusKeeper.UpdateFileChecksum(targetPath, tuple.ObjectInfo.ETag,\r
- tuple.ObjectInfo.X_Object_Hash);\r
-\r
- StatusKeeper.StoreInfo(targetPath, tuple.ObjectInfo);\r
+ //Server file doesn't exist\r
+ //deleteObjectFromLocal()\r
+ StatusKeeper.SetFileState(localFilePath, FileStatus.Deleted,\r
+ FileOverlayStatus.Deleted, "");\r
+ agent.Delete(localFilePath);\r
+ //updateRecord(Remove C, L)\r
+ StatusKeeper.ClearFileStatus(localFilePath);\r
+ }\r
+ else\r
+ {\r
+ //Server file exists\r
+ //downloadServerObject() // Result: L = S\r
+ //If the file has moved on the server, move it locally before downloading\r
+ var targetPath = MoveForServerMove(accountInfo, tuple);\r
+\r
+ StatusKeeper.SetFileState(targetPath, FileStatus.Modified,\r
+ FileOverlayStatus.Modified, "");\r
+ NetworkAgent.Downloader.DownloadCloudFile(accountInfo,\r
+ tuple.ObjectInfo,\r
+ targetPath, tuple.Merkle, token).Wait(token);\r
+ //updateRecord( L = S )\r
+ StatusKeeper.UpdateFileChecksum(targetPath, tuple.ObjectInfo.ETag,\r
+ tuple.ObjectInfo.X_Object_Hash);\r
+\r
+ StatusKeeper.StoreInfo(targetPath, tuple.ObjectInfo);\r
\r
-/*\r
- StatusKeeper.SetFileState(targetPath, FileStatus.Unchanged,\r
- FileOverlayStatus.Normal, "");\r
-*/\r
- }\r
+ /*\r
+ StatusKeeper.SetFileState(targetPath, FileStatus.Unchanged,\r
+ FileOverlayStatus.Normal, "");\r
+ */\r
}\r
}\r
+\r
}\r
else\r
{\r
else\r
{\r
//uploadLocalObject() // Result: S = C, L = S \r
- var isUnselected = agent.IsUnselectedRootFolder(tuple.FilePath);\r
\r
//Debug.Assert(tuple.FileState !=null);\r
var action = new CloudUploadAction(accountInfo, localInfo, tuple.FileState,\r
accountInfo.BlockSize, accountInfo.BlockHash,\r
- "Poll", isUnselected);\r
- NetworkAgent.Uploader.UploadCloudFile(action, tuple.Merkle,token).Wait(token);\r
+ "Poll", isUnselectedRootFolder);\r
+ NetworkAgent.Uploader.UploadCloudFile(action, tuple.Merkle, token).Wait(token);\r
\r
//updateRecord( S = C )\r
//State updated by the uploader\r
- \r
- if (isUnselected)\r
+\r
+ if (isUnselectedRootFolder)\r
{\r
ProcessChildren(accountInfo, tuple, agent, token);\r
}\r
}\r
else\r
{\r
- if (Selectives.IsSelected(accountInfo, localFilePath))\r
+ if (tuple.C == tuple.S)\r
{\r
- if (tuple.C == tuple.S)\r
+ // (Identical Changes) Result: L = S\r
+ //doNothing()\r
+ //Detect server moves\r
+ var targetPath = MoveForServerMove(accountInfo, tuple);\r
+ StatusKeeper.StoreInfo(targetPath, tuple.ObjectInfo);\r
+ }\r
+ else\r
+ {\r
+ if ((tuple.C == null || !localInfo.Exists) && tuple.ObjectInfo != null)\r
+ {\r
+ //deleteObjectFromServer()\r
+ DeleteCloudFile(accountInfo, tuple);\r
+ //updateRecord(Remove L, S) \r
+ }\r
+ //If both the local and server files are missing, the state is stale\r
+ else if (!localInfo.Exists && (tuple.S == null || tuple.ObjectInfo == null))\r
{\r
- // (Identical Changes) Result: L = S\r
- //doNothing()\r
- //Detect server moves\r
- var targetPath=MoveForServerMove(accountInfo, tuple);\r
- StatusKeeper.StoreInfo(targetPath,tuple.ObjectInfo);\r
+ StatusKeeper.ClearFileStatus(localInfo.FullName);\r
}\r
else\r
{\r
- if ((tuple.C == null || !localInfo.Exists) && tuple.ObjectInfo != null )\r
- {\r
- //deleteObjectFromServer()\r
- DeleteCloudFile(accountInfo, tuple);\r
- //updateRecord(Remove L, S) \r
- }\r
- //If both the local and server files are missing, the state is stale\r
- else if (!localInfo.Exists && ( tuple.S==null || tuple.ObjectInfo==null))\r
- {\r
- StatusKeeper.ClearFileStatus(localInfo.FullName);\r
- }\r
- else\r
- {\r
- ReportConflictForMismatch(localFilePath);\r
- //identifyAsConflict() // Manual action required\r
- }\r
+ ReportConflictForMismatch(localFilePath);\r
+ //identifyAsConflict() // Manual action required\r
}\r
}\r
}\r