From 3928e116117606fac9d677d0ad8f54ec5038f3ec Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Tue, 18 Apr 2017 13:51:08 -0700 Subject: [PATCH] fix valid byte range check and send asset from 0 --- assignment-client/src/assets/SendAssetTask.cpp | 2 +- libraries/networking/src/ByteRange.h | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/assignment-client/src/assets/SendAssetTask.cpp b/assignment-client/src/assets/SendAssetTask.cpp index cb99636e83..5a394eaa07 100644 --- a/assignment-client/src/assets/SendAssetTask.cpp +++ b/assignment-client/src/assets/SendAssetTask.cpp @@ -88,7 +88,7 @@ void SendAssetTask::run() { auto size = byteRange.size(); - if (byteRange.fromInclusive > 0) { + if (byteRange.fromInclusive >= 0) { // this range is positive, meaning we just need to seek into the file and then read from there file.seek(byteRange.fromInclusive); diff --git a/libraries/networking/src/ByteRange.h b/libraries/networking/src/ByteRange.h index 3993bac324..b5e214605d 100644 --- a/libraries/networking/src/ByteRange.h +++ b/libraries/networking/src/ByteRange.h @@ -24,9 +24,9 @@ struct ByteRange { // (2) the toExclusive of the range is less than the fromInclusive, and isn't zero // (3) the fromExclusive of the range is negative, and the toExclusive isn't zero bool isValid() { - return toExclusive < 0 - || (toExclusive < fromInclusive && toExclusive != 0) - || (fromInclusive < 0 && toExclusive != 0); + return toExclusive >= 0 + && (toExclusive >= fromInclusive || toExclusive == 0) + && (fromInclusive >= 0 || toExclusive == 0); } void fixupRange(int64_t fileSize) {