Report a disk switch if the length of the file changed.

Currently, the logic for this doesn't re-detect the file type, and it may not work correctly with some 2mg files, but it should work in most cases.
This commit is contained in:
Stephen Heumann 2018-10-01 01:40:49 -05:00
parent 28fd51d175
commit 314f408b5e
3 changed files with 16 additions and 3 deletions

View File

@ -337,7 +337,18 @@ static Word DoRead(struct GSOSDP *dp) {
enum NetDiskError err = DoHTTPRequest(sess, readStart, readEnd);
if (err != OPERATION_SUCCESSFUL) {
dp->transferCount = 0;
return drvrIOError;
if (err == DIFFERENT_LENGTH) {
if ((sess->totalLength - sess->dataOffset) % BLOCK_SIZE != 0) {
return drvrIOError;
} else {
sess->dataLength = sess->totalLength - sess->dataOffset;
dp->dibPointer->blockCount = sess->dataLength / BLOCK_SIZE;
sess->expectedLength = sess->totalLength;
return drvrDiskSwitch;
}
} else {
return drvrIOError;
}
}
ReadStatus readStatus;

4
http.c
View File

@ -363,7 +363,9 @@ netRetry:
}
/* See if we got what we wanted */
if (sess->expectedLength != 0 && sess->totalLength != sess->expectedLength) {
if (sess->expectedLength == 0) {
sess->expectedLength = sess->totalLength;
} else if (sess->totalLength != sess->expectedLength) {
result = DIFFERENT_LENGTH;
goto errorReturn;
}

View File

@ -31,7 +31,7 @@ enum NetDiskError {
UNSUPPORTED_HEADER_VALUE,
REDIRECT_ERROR,
NOT_DESIRED_CONTENT,
DIFFERENT_LENGTH, /* Might be considered successful later */
DIFFERENT_LENGTH,
/* Error values of 4xx and 5xx mean we got the corresponding HTTP error */
HTTP_ERROR = 400,