From 9a8cf57c754e9a9282c37fd8e88b9d397ba29f58 Mon Sep 17 00:00:00 2001 From: Mikhail Filippov Date: Fri, 25 Aug 2017 00:50:59 +0300 Subject: [PATCH] Fix VerifyUploadFileAsync for long files. #79 --- src/VimeoDotNet/VimeoClient_Upload.cs | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/src/VimeoDotNet/VimeoClient_Upload.cs b/src/VimeoDotNet/VimeoClient_Upload.cs index d6793bc..3bc9471 100644 --- a/src/VimeoDotNet/VimeoClient_Upload.cs +++ b/src/VimeoDotNet/VimeoClient_Upload.cs @@ -224,11 +224,7 @@ public async Task UploadEntireFileAsync(IBinaryContent fileConte return uploadRequest; } - /// - /// Verify upload file part asynchronously - /// - /// UploadRequest - /// Verification reponse + /// public async Task VerifyUploadFileAsync(IUploadRequest uploadRequest) { try @@ -239,6 +235,7 @@ public async Task VerifyUploadFileAsync(IUploadRequest upl var verify = new VerifyUploadResponse(); CheckStatusCodeError(uploadRequest, response, "Error verifying file upload.", (HttpStatusCode)308); + // ReSharper disable once ConvertIfStatementToSwitchStatement if (response.StatusCode == HttpStatusCode.OK) { verify.BytesWritten = uploadRequest.FileLength; @@ -249,12 +246,11 @@ public async Task VerifyUploadFileAsync(IUploadRequest upl verify.Status = UploadStatusEnum.InProgress; if (!response.Headers.Contains("Range")) return verify; - var startIndex = 0; - var endIndex = 0; var match = RangeRegex.Match(response.Headers.GetValues("Range").First()); + // ReSharper disable once InvertIf if (match.Success - && int.TryParse(match.Groups["start"].Value, out startIndex) - && int.TryParse(match.Groups["end"].Value, out endIndex)) + && long.TryParse(match.Groups["start"].Value, out var startIndex) + && long.TryParse(match.Groups["end"].Value, out var endIndex)) { verify.BytesWritten = endIndex - startIndex; if (verify.BytesWritten == uploadRequest.FileLength)