Added cloning of HttpRequestMessage to allow retries using the messages themselves
[pithos-ms-client] / trunk / Pithos.Core / PithosMonitor.cs
index ec51f4f..c9526a6 100644 (file)
@@ -241,10 +241,10 @@ namespace Pithos.Core
             //Create the cache folder and ensure it is hidden\r
             CreateHiddenFolder(RootPath, FolderConstants.CacheFolder);\r
 \r
-            var policy=CloudClient.GetAccountPolicies(_accountInfo);\r
+            var policy=await CloudClient.GetAccountPolicies(_accountInfo);\r
 \r
             StatusNotification.NotifyAccount(policy);\r
-            EnsurePithosContainers();\r
+            await EnsurePithosContainers().ConfigureAwait(false);\r
             \r
             StatusKeeper.BlockHash = _blockHash;\r
             StatusKeeper.BlockSize = _blockSize;\r
@@ -275,7 +275,7 @@ namespace Pithos.Core
             CleanupUnselectedStates();\r
         }\r
 \r
-        private void EnsurePithosContainers()\r
+        private async Task EnsurePithosContainers()\r
         {\r
 \r
             //Create the two default containers if they are missing\r
@@ -283,11 +283,11 @@ namespace Pithos.Core
             foreach (var container in pithosContainers)\r
             {\r
                 var escapedUri = container.ToEscapedUri();\r
-                var info=CloudClient.GetContainerInfo(UserName, escapedUri);\r
+                var info=await CloudClient.GetContainerInfo(UserName, escapedUri).ConfigureAwait(false);\r
                 if (info == ContainerInfo.Empty)\r
                 {\r
-                    CloudClient.CreateContainer(UserName, escapedUri);\r
-                    info = CloudClient.GetContainerInfo(UserName, escapedUri);\r
+                    await CloudClient.CreateContainer(UserName, escapedUri);\r
+                    info = await CloudClient.GetContainerInfo(UserName, escapedUri).ConfigureAwait(false);\r
                 }\r
                 _blockSize = info.BlockSize;\r
                 _blockHash = info.BlockHash;\r
@@ -554,7 +554,7 @@ namespace Pithos.Core
         }\r
 \r
 \r
-        public ObjectInfo GetObjectInfo(string filePath)\r
+        public async Task<ObjectInfo> GetObjectInfo(string filePath)\r
         {\r
             if (String.IsNullOrWhiteSpace(filePath))\r
                 throw new ArgumentNullException("filePath");\r
@@ -598,11 +598,11 @@ namespace Pithos.Core
             }\r
             \r
             var client = new CloudFilesClient(accountInfo);\r
-            var objectInfo=client.GetObjectInfo(accountName, container.ToEscapedUri(), relativeUrl.ToEscapedUri());\r
+            var objectInfo=await client.GetObjectInfo(accountName, container.ToEscapedUri(), relativeUrl.ToEscapedUri()).ConfigureAwait(false);\r
             return objectInfo;\r
         }\r
         \r
-        public Task<ContainerInfo> GetContainerInfo(string filePath)\r
+        public async Task<ContainerInfo> GetContainerInfo(string filePath)\r
         {\r
             if (String.IsNullOrWhiteSpace(filePath))\r
                 throw new ArgumentNullException("filePath");\r
@@ -642,12 +642,11 @@ namespace Pithos.Core
                 container = parts[0];                \r
             }\r
 \r
-            return Task.Factory.StartNew(() =>\r
-            {\r
-                var client = new CloudFilesClient(accountInfo);\r
-                var containerInfo = client.GetContainerInfo(accountName, container.ToEscapedUri());\r
-                return containerInfo;\r
-            });\r
+            \r
+            var client = new CloudFilesClient(accountInfo);\r
+            var containerInfo = await client.GetContainerInfo(accountName, container.ToEscapedUri()).ConfigureAwait(false);\r
+            return containerInfo;\r
+            \r
         }\r
     }\r
 }\r