Convert all url usages to use the Uri class instead of raw strings.
[pithos-ms-client] / trunk / Pithos.Core / Agents / Downloader.cs
index ea480ff..584141a 100644 (file)
@@ -43,7 +43,9 @@ namespace Pithos.Core.Agents
                 throw new ArgumentNullException("cloudFile");\r
             if (String.IsNullOrWhiteSpace(cloudFile.Account))\r
                 throw new ArgumentNullException("cloudFile");\r
-            if (String.IsNullOrWhiteSpace(cloudFile.Container))\r
+            if (cloudFile.Container==null)\r
+                throw new ArgumentNullException("cloudFile");\r
+            if (cloudFile.Container.IsAbsoluteUri)\r
                 throw new ArgumentNullException("cloudFile");\r
             if (String.IsNullOrWhiteSpace(filePath))\r
                 throw new ArgumentNullException("filePath");\r
@@ -76,10 +78,10 @@ namespace Pithos.Core.Agents
                     }\r
                     \r
                     var localPath = info.FullName;\r
-                    var relativeUrl = new Uri(cloudFile.Name, UriKind.Relative);\r
+                    var relativeUrl = cloudFile.Name;\r
 \r
                     var url = relativeUrl.ToString();\r
-                    if (cloudFile.Name.EndsWith(".ignore", StringComparison.InvariantCultureIgnoreCase))\r
+                    if (url.EndsWith(".ignore", StringComparison.InvariantCultureIgnoreCase))\r
                         return finalHash;\r
 \r
                     if (!Selectives.IsSelected(accountInfo,cloudFile))\r
@@ -124,7 +126,7 @@ namespace Pithos.Core.Agents
                             if (isChanged)\r
                             {\r
                                 //Retrieve the hashmap from the server\r
-                                var serverHash = await client.GetHashMap(account, container, url).ConfigureAwait(false);\r
+                                var serverHash = await client.GetHashMap(account, container, relativeUrl).ConfigureAwait(false);\r
                                 //If it's a small file\r
                                 if (serverHash.Hashes.Count == 1)\r
                                     //Download it in one go\r
@@ -291,7 +293,7 @@ namespace Pithos.Core.Agents
                 Directory.CreateDirectory(tempFolder);\r
 \r
             //Download the object to the temporary location\r
-            await client.GetObject(cloudFile.Account, cloudFile.Container, relativeUrl.ToString(), tempPath, cancellationToken).ConfigureAwait(false);\r
+            await client.GetObject(cloudFile.Account, cloudFile.Container, relativeUrl, tempPath, cancellationToken).ConfigureAwait(false);\r
 \r
             //Create the local folder if it doesn't exist (necessary for shared objects)\r
             var localFolder = Path.GetDirectoryName(localPath);\r