X-Git-Url: https://code.grnet.gr/git/pithos-ms-client/blobdiff_plain/d5617d4f6182853060bfa2bc665e341834e23768..d7288179638247cb10a9abec6f85503d1c72315f:/trunk/Pithos.Core/Agents/Uploader.cs diff --git a/trunk/Pithos.Core/Agents/Uploader.cs b/trunk/Pithos.Core/Agents/Uploader.cs index c27a731..8c49a67 100644 --- a/trunk/Pithos.Core/Agents/Uploader.cs +++ b/trunk/Pithos.Core/Agents/Uploader.cs @@ -1,13 +1,10 @@ using System; -using System.Collections.Generic; using System.ComponentModel.Composition; using System.Diagnostics; using System.Diagnostics.Contracts; using System.IO; -using System.Linq; using System.Net; using System.Reflection; -using System.Security.Cryptography; using System.Threading; using System.Threading.Tasks; using Pithos.Interfaces; @@ -168,7 +165,7 @@ namespace Pithos.Core.Agents if (action.IsCreation) { //Add the folder to the Selected URls - var selectiveUri = new Uri(client.RootAddressUri, cloudFile.Uri); + var selectiveUri = client.RootAddressUri.Combine(cloudFile.Uri); Selectives.AddUri(accountInfo, selectiveUri); Selectives.Save(accountInfo); } @@ -315,7 +312,7 @@ namespace Pithos.Core.Agents } - public async Task UploadWithHashMap(AccountInfo accountInfo, ObjectInfo cloudFile, FileInfo fileInfo, string url, TreeHash treeHash, CancellationToken token) + public async Task UploadWithHashMap(AccountInfo accountInfo, ObjectInfo cloudFile, FileInfo fileInfo, Uri uri, TreeHash treeHash, CancellationToken token) { if (accountInfo == null) throw new ArgumentNullException("accountInfo"); @@ -323,12 +320,14 @@ namespace Pithos.Core.Agents throw new ArgumentNullException("cloudFile"); if (fileInfo == null) throw new ArgumentNullException("fileInfo"); - if (String.IsNullOrWhiteSpace(url)) - throw new ArgumentNullException(url); + if (uri==null) + throw new ArgumentNullException("uri"); if (treeHash == null) throw new ArgumentNullException("treeHash"); - if (String.IsNullOrWhiteSpace(cloudFile.Container)) + if (cloudFile.Container==null) throw new ArgumentException("Invalid container", "cloudFile"); + if (cloudFile.Container.IsAbsoluteUri) + throw new ArgumentException("Container URI must be relative", "cloudFile"); Contract.EndContractBlock(); @@ -344,7 +343,7 @@ namespace Pithos.Core.Agents var client = new CloudFilesClient(accountInfo); //Send the hashmap to the server - var missingHashes = await client.PutHashMap(account, container, url, treeHash).ConfigureAwait(false); + var missingHashes = await client.PutHashMap(account, container, uri, treeHash).ConfigureAwait(false); ReportUploadProgress(fileInfo.Name, block, 0, missingHashes.Count, fileInfo.Length); //If the server returns no missing hashes, we are done @@ -384,7 +383,7 @@ namespace Pithos.Core.Agents token.ThrowIfCancellationRequested(); Log.InfoFormat("[BLOCK] Block {0} of {1} uploaded", blockIndex, fullFileName); } - catch (TaskCanceledException exc) + catch (TaskCanceledException) { throw new OperationCanceledException(token); } @@ -397,7 +396,7 @@ namespace Pithos.Core.Agents token.ThrowIfCancellationRequested(); //Repeat until there are no more missing hashes - missingHashes = await client.PutHashMap(account, container, url, treeHash).ConfigureAwait(false); + missingHashes = await client.PutHashMap(account, container, uri, treeHash).ConfigureAwait(false); } ReportUploadProgress(fileInfo.Name, missingHashes.Count, 0, missingHashes.Count, fileInfo.Length);