OneDrive / onedrive-sdk-csharp

OneDrive SDK for C#! https://dev.onedrive.com
Other
295 stars 145 forks source link

Big files, ChunkedUploadProvider goes in an infinite loop #230

Closed IliqNikushev closed 7 years ago

IliqNikushev commented 7 years ago

Hello,

I noticed a small issue while having to upload big files (with byte length > int.MaxValue (2GB)) Reason being session.NextExpectedRanges sometimes returned 0...(Size of the file)

ChunkedUploadProvider#217 The problem is that the method returns int, while doing operations with long

private int NextChunkSize(long rangeBegin, long rangeEnd)
  var sizeBasedOnRange = (int) (rangeEnd - rangeBegin) + 1;

rangeEnd being > 2GB makes rangeEnd - rangeBeing < 0 This makes the loop GetUploadChunkRequests go on infinitely

What I did is using long, then casting to int

long sizeBasedOnRange = (rangeEnd - rangeBegin) + 1;
    return sizeBasedOnRange > this.maxChunkSize
      ? this.maxChunkSize
      : (int)sizeBasedOnRange;

Big thank you on the awesome work you are doing!

IliqNikushev commented 7 years ago

solved by https://github.com/OneDrive/onedrive-sdk-csharp/pull/232