Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

get_chunk_size() is returning incorrect file size when chunk index is > 1 and the file size is less than 3 * MAX_CHUNK_SIZE #381

Open
traktion opened this issue Apr 17, 2024 · 2 comments
Labels

Comments

@traktion
Copy link
Contributor

Thank you for contributing to the project!
We recommend you check out our "Contributing to the SAFE Network" guide if you haven't already.

Describe the bug

Originally found through integrating sn_client libraries into sn_httpd: maidsafe/safe_network#1621 (comment)

In short, when attempting to retrieve small parts of medium sized files (up to 1.5 MB), the relative_pos is incorrectly calculated for index 2+. This results in relative_pos being too low, causing an overlap with prior calls to seek_info when stepping through a file.

To Reproduce
Steps to reproduce the behavior:

  1. Call seek_info with a file smaller than 1.5 MB, using a small length such as 64 KB and increment the pos by 64 KB each time.
  2. Once index 2 is referenced, the relative_pos will return duplicate bytes from the prior call.

Expected behavior
There should be no duplicate bytes returned from prior calls to seek_info().

Screenshots
This is a comparison between 2 files, one using a large length (512 KB) which is successful, vs one which used 128 KB and had duplicate bytes:

Screenshot from 2024-04-16 09-53-55

Desktop (please complete the followin
g information):

  • OS: Linux

Smartphone (please complete the following information):

  • Device: Laptop

Additional context

@traktion traktion added the bug label Apr 17, 2024
@traktion
Copy link
Contributor Author

I have a PR to fix this issue, but I don't think I have permission to create a branch.

@traktion
Copy link
Contributor Author

PR here: #382

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant