Skip to content

Conversation

@odesenfans
Copy link
Collaborator

@odesenfans odesenfans commented Apr 24, 2023

Four fixes:

  • files uploaded with the add_file/add_json endpoints are not downloadable.
  • /ipfs/add_file is broken.
  • /ipfs/add_file returned the wrong size, and we store the wrong size for IPFS files above 1MB when processing STORE messages.
  • Unrelated, but the test API server was unable to use the IPFS client, making the fixes above harder to test locally.

Problem: when a user uploads a file with the /storage and /ipfs
add_file/add_json endpoints, the corresponding files are not
downloadable until a corresponding STORE message is processed.
This is problematic if the message is not sent to the same node
or if the message fails to be processed because of a bug. The file
would then be impossible to download, making the message unprocessable
for other nodes.

Solution: add an entry in the `files` table for each uploaded file.
Problem: POST /ipfs/add_file returns a 500 in all cases.
Solution: fix the URI, a typo was introduced that made the IPFS
daemon URI look like /api/v0/api/v0/<endpoint> instead of just
/api/v0/<endpoint>.
Problem: we create the aiohttp app in a separate coroutine, which
results in an "event loop is closed" error when using some functions
of the IPFS client.

Solution: do not initialize the app ourselves and let web.run_app()
do it by passing the create_app() coroutine as argument.
@odesenfans odesenfans force-pushed the od-fix-storage-api-bugs branch 4 times, most recently from 487bf35 to cdb16b0 Compare April 25, 2023 09:46
Problem: we use the cumulative size in /ipfs/add_file and when
processing STORE messages for files above 1MB.

Solution: use the cumulative size for directories and use the size
field for everything else.
@odesenfans odesenfans force-pushed the od-fix-storage-api-bugs branch from cdb16b0 to 016d5cc Compare April 25, 2023 13:17
@odesenfans odesenfans merged commit 4766051 into aleph-im:dev Apr 25, 2023
@odesenfans odesenfans deleted the od-fix-storage-api-bugs branch April 25, 2023 13:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant