mirror of
https://github.com/sheumann/NetDisk.git
synced 2024-11-23 22:37:02 +00:00
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:
parent
28fd51d175
commit
314f408b5e
13
driver.c
13
driver.c
@ -337,7 +337,18 @@ static Word DoRead(struct GSOSDP *dp) {
|
|||||||
enum NetDiskError err = DoHTTPRequest(sess, readStart, readEnd);
|
enum NetDiskError err = DoHTTPRequest(sess, readStart, readEnd);
|
||||||
if (err != OPERATION_SUCCESSFUL) {
|
if (err != OPERATION_SUCCESSFUL) {
|
||||||
dp->transferCount = 0;
|
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;
|
ReadStatus readStatus;
|
||||||
|
4
http.c
4
http.c
@ -363,7 +363,9 @@ netRetry:
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* See if we got what we wanted */
|
/* 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;
|
result = DIFFERENT_LENGTH;
|
||||||
goto errorReturn;
|
goto errorReturn;
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,7 @@ enum NetDiskError {
|
|||||||
UNSUPPORTED_HEADER_VALUE,
|
UNSUPPORTED_HEADER_VALUE,
|
||||||
REDIRECT_ERROR,
|
REDIRECT_ERROR,
|
||||||
NOT_DESIRED_CONTENT,
|
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 */
|
/* Error values of 4xx and 5xx mean we got the corresponding HTTP error */
|
||||||
HTTP_ERROR = 400,
|
HTTP_ERROR = 400,
|
||||||
|
Loading…
Reference in New Issue
Block a user