Repository navigation
Conversation
The multipart download loop runs floor(size/chunk)+1 times. For any size that is not an exact multiple of the chunk size that equals ceil(size/chunk), so the extra trip is harmless and the bug is invisible. When the size *is* an exact multiple it is one trip too many, and that trip requests "bytes=<size>-<size+chunk-1>" - a range starting at EOF, which the Graph API answers with HTTP 416. GetItemContentStream returns that as a fatal error, so the file can never be read: every open() fails with EREMOTEIO for as long as the content is not cached, and clearing the cache only forces the failing path again. Observed on a 146800640 byte file, exactly 14 chunks: all 14 ranges download, then a 15th is requested and fails. In a tree of ~88600 files, every file whose size was an exact multiple of 10485760 was unreadable, and no other file was affected.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Symptom
Some files can never be read through the mount. Every
open()fails withEREMOTEIO("Remote I/O error"), and the log shows the whole file downloading successfully and then one request too many:It looks intermittent, because it only happens when onedriver actually takes the download path — a cache miss, or
Not using cached item due to file hash mismatch. Clearing the cache makes it worse, since a miss is exactly what forces the failing path.Cause
GetItemContentStreaminfs/graph/drive_item.goruns the multipart loopfloor(size/chunk) + 1times. That equalsceil(size/chunk)for every size except an exact multiple of the chunk size, where it is one trip too many. The final request then asks forbytes=<size>-<size+chunk-1>— a range starting at EOF — which the Graph API correctly rejects with416 Range Not Satisfiable. The error is returned as fatal, so the item is unreadable for good.So the condition is exactly:
size % 10485760 == 0andsize > 10485760. Sizes at or below one chunk take the one-shot path and are unaffected.Fix
One line — use
ceilinstead offloor + 1:Verification
In a tree of ~88,600 files, 32 had a size that was an exact multiple of 10485760. Of those, 24 were re-fetched during a verification pass and all 24 failed; the remaining 8 were served from cache and never hit the download path. Of the ~88,570 files whose size was not an exact multiple, none failed for this reason — including 179 files of the same type and similar sizes.
After the fix, all 24 read and hash correctly, and no other file changed behaviour.
The arithmetic on its own is decisive:
Notes
GetItemContentStream, which needs an authenticated Graph client, so covering it would mean extracting the trip count into its own function first. Happy to do that if you'd prefer it tested.