Resolve Key not found: nextExpectedRanges (Issue #408) (#409)

* Dont 'assume' that the key value pairs exist. Check if they do before attempting to use them
This commit is contained in:
abraunegg 2019-03-12 11:49:15 +11:00 committed by GitHub
parent 98624267c5
commit e849eb3de4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -111,8 +111,16 @@ struct UploadSession
JSONValue upload()
{
long offset = session["nextExpectedRanges"][0].str.splitter('-').front.to!long;
long fileSize = getSize(session["localPath"].str);
long offset;
long fileSize;
if ("nextExpectedRanges" in session){
offset = session["nextExpectedRanges"][0].str.splitter('-').front.to!long;
}
if ("localPath" in session){
fileSize = getSize(session["localPath"].str);
}
// Upload Progress Bar
size_t iteration = (roundTo!int(double(fileSize)/double(fragmentSize)))+1;