diff --git a/src/AVPRClient/AVPRClient.cs b/src/AVPRClient/AVPRClient.cs index fcbd22a..554ab91 100644 --- a/src/AVPRClient/AVPRClient.cs +++ b/src/AVPRClient/AVPRClient.cs @@ -243,6 +243,16 @@ public virtual async System.Threading.Tasks.Task CreatePackag throw new ApiException("A server side error occurred.", status_, responseText_, headers_, null); } else + if (status_ == 422) + { + var objectResponse_ = await ReadObjectResponseAsync(response_, headers_, cancellationToken).ConfigureAwait(false); + if (objectResponse_.Object == null) + { + throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null); + } + throw new ApiException("A server side error occurred.", status_, objectResponse_.Text, headers_, objectResponse_.Object, null); + } + else { var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); throw new ApiException("The HTTP status code of the response was not expected (" + status_ + ").", status_, responseData_, headers_, null); @@ -602,107 +612,6 @@ public virtual async System.Threading.Tasks.Task VerifyPackageContentAsync(Packa } } - /// - /// Create a content hash for a given package. - /// - /// - /// Create a content hash for a given package. Hashes are MD5 hex fingerprints. This Endpoint requires API Key authentication. - /// - /// A server side error occurred. - public virtual System.Threading.Tasks.Task CreatePackageContentHashAsync(PackageContentHash hashedPackage) - { - return CreatePackageContentHashAsync(hashedPackage, System.Threading.CancellationToken.None); - } - - /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. - /// - /// Create a content hash for a given package. - /// - /// - /// Create a content hash for a given package. Hashes are MD5 hex fingerprints. This Endpoint requires API Key authentication. - /// - /// A server side error occurred. - public virtual async System.Threading.Tasks.Task CreatePackageContentHashAsync(PackageContentHash hashedPackage, System.Threading.CancellationToken cancellationToken) - { - if (hashedPackage == null) - throw new System.ArgumentNullException("hashedPackage"); - - var client_ = _httpClient; - var disposeClient_ = false; - try - { - using (var request_ = new System.Net.Http.HttpRequestMessage()) - { - var json_ = Newtonsoft.Json.JsonConvert.SerializeObject(hashedPackage, _settings.Value); - var content_ = new System.Net.Http.StringContent(json_); - content_.Headers.ContentType = System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json"); - request_.Content = content_; - request_.Method = new System.Net.Http.HttpMethod("POST"); - request_.Headers.Accept.Add(System.Net.Http.Headers.MediaTypeWithQualityHeaderValue.Parse("application/json")); - - var urlBuilder_ = new System.Text.StringBuilder(); - if (!string.IsNullOrEmpty(_baseUrl)) urlBuilder_.Append(_baseUrl); - // Operation Path: "api/v1/verify/hashes" - urlBuilder_.Append("api/v1/verify/hashes"); - - PrepareRequest(client_, request_, urlBuilder_); - - var url_ = urlBuilder_.ToString(); - request_.RequestUri = new System.Uri(url_, System.UriKind.RelativeOrAbsolute); - - PrepareRequest(client_, request_, url_); - - var response_ = await client_.SendAsync(request_, System.Net.Http.HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false); - var disposeResponse_ = true; - try - { - var headers_ = new System.Collections.Generic.Dictionary>(); - foreach (var item_ in response_.Headers) - headers_[item_.Key] = item_.Value; - if (response_.Content != null && response_.Content.Headers != null) - { - foreach (var item_ in response_.Content.Headers) - headers_[item_.Key] = item_.Value; - } - - ProcessResponse(client_, response_); - - var status_ = (int)response_.StatusCode; - if (status_ == 200) - { - var objectResponse_ = await ReadObjectResponseAsync(response_, headers_, cancellationToken).ConfigureAwait(false); - if (objectResponse_.Object == null) - { - throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null); - } - return objectResponse_.Object; - } - else - if (status_ == 409) - { - string responseText_ = ( response_.Content == null ) ? string.Empty : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); - throw new ApiException("A server side error occurred.", status_, responseText_, headers_, null); - } - else - { - var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); - throw new ApiException("The HTTP status code of the response was not expected (" + status_ + ").", status_, responseData_, headers_, null); - } - } - finally - { - if (disposeResponse_) - response_.Dispose(); - } - } - } - finally - { - if (disposeClient_) - client_.Dispose(); - } - } - /// /// Get all download statistics /// diff --git a/src/AVPRClient/AVPRClient.csproj b/src/AVPRClient/AVPRClient.csproj index 5a86a56..652ebfb 100644 --- a/src/AVPRClient/AVPRClient.csproj +++ b/src/AVPRClient/AVPRClient.csproj @@ -22,13 +22,27 @@ git $([System.IO.File]::ReadAllText("$(MSBuildProjectDirectory)/RELEASE_NOTES.md")) README.md - 0.0.7 + 0.0.8 - + - + + + + <_ProjectReferenceWithExplicitPackageVersion Include="@(ProjectReference->'%(FullPath)')" Condition="'%(ProjectReference.PackageVersion)' != ''" /> + <_ProjectReferenceWithExactPackageVersion Include="@(ProjectReference->'%(FullPath)')" Condition="'%(ProjectReference.ExactVersion)' == 'true'" /> + <_ProjectReferenceWithReassignedVersion Include="@(_ProjectReferencesWithVersions)" Condition="'%(Identity)' != '' And '@(_ProjectReferenceWithExplicitPackageVersion)' == '@(_ProjectReferencesWithVersions)'"> + @(_ProjectReferenceWithExplicitPackageVersion->'%(PackageVersion)') + + <_ProjectReferenceWithReassignedVersion Include="@(_ProjectReferencesWithVersions)" Condition="'%(Identity)' != '' And '@(_ProjectReferenceWithExactPackageVersion)' == '@(_ProjectReferencesWithVersions)'"> + @(_ProjectReferenceWithExplicitPackageVersion->'%(PackageVersion)') + + <_ProjectReferencesWithVersions Remove="@(_ProjectReferenceWithReassignedVersion)" /> + <_ProjectReferencesWithVersions Include="@(_ProjectReferenceWithReassignedVersion)" /> + + \ No newline at end of file diff --git a/src/AVPRClient/Extensions.cs b/src/AVPRClient/Extensions.cs index e628e73..303bd8c 100644 --- a/src/AVPRClient/Extensions.cs +++ b/src/AVPRClient/Extensions.cs @@ -72,18 +72,10 @@ public static AVPRClient.PackageContentHash toPackageContentHash( { if ( HashFileDirectly) { - MD5 md5 = MD5.Create(); return new AVPRClient.PackageContentHash { PackageName = indexedPackage.Metadata.Name, - Hash = Convert.ToHexString( - md5.ComputeHash( - Encoding.UTF8.GetBytes( - File.ReadAllText(indexedPackage.RepoPath) - .ReplaceLineEndings("\n") - ) - ) - ), + Hash = Hash.hashFile(indexedPackage.RepoPath), PackageMajorVersion = indexedPackage.Metadata.MajorVersion, PackageMinorVersion = indexedPackage.Metadata.MinorVersion, PackagePatchVersion = indexedPackage.Metadata.PatchVersion diff --git a/src/AVPRClient/RELEASE_NOTES.md b/src/AVPRClient/RELEASE_NOTES.md index 3692e16..28685a7 100644 --- a/src/AVPRClient/RELEASE_NOTES.md +++ b/src/AVPRClient/RELEASE_NOTES.md @@ -1,3 +1,6 @@ +## v0.0.8 +- Use AVPRIndex for all package hash calculations + ## v0.0.7 - Further TypeExtension improvements and fixes