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

Fix file download issues #291

Open
wants to merge 2 commits into
base: beta
Choose a base branch
from

Conversation

makermelissa
Copy link
Collaborator

@makermelissa makermelissa commented Jan 31, 2025

Fixes #290. This also updates the version of circuitpython-repl-js with some fixes in it that were added in adafruit/circuitpython-repl-js#15.

@makermelissa makermelissa requested a review from FoamyGuy January 31, 2025 21:15
@makermelissa
Copy link
Collaborator Author

I think this may also fix #289 as status works when running locally on my machine.

@FoamyGuy
Copy link

FoamyGuy commented Feb 1, 2025

I am trying to run this branch locally but I am still having trouble downloading files and folders.

If I select a single file like code.py and click the download button I see the loading indicator spin, then it goes away but no file is downloaded. In the console it prints this error message:

Uncaught (in promise) TypeError: Failed to execute 'createObjectURL' on 'URL': Overload resolution failed.
    at g (file-saver.js?v=b3c4113b:47:224)
    at FileDialog._download (file_dialog.js:614:9)
    at async FileDialog._handleDownloadButton (file_dialog.js:555:9)

If I instead select a folder like lib/ and click the download button it does download a file lib.zip but the file is only 22 bytes and my OS reports that it's an empty archive when I attempt to extract it. I do have 3 .mpy files inside of lib on the device but they don't end up inside of the zip for me.

I'm not sure if I understand fully how version numbers work with NPM modules. I saw in this change that adafruit/circuitpython-repl-js is moved to version 3.2.2. After pulling this branch and running npm install I noticed that inside of node_modules/@adafruit/circuitpython-repl-js/package.json I see "version": "2.0.1",. Does this mean that I am not successfully getting the version specified in this branch?

@FoamyGuy
Copy link

FoamyGuy commented Feb 1, 2025

I have found and run npm update and then npm install again. After that I am now able to successfully download single files like code.py however downloading a folder like lib/ is still resulting in an empty zip. there are no errors or other console output during the folder download attempt.

The package.json inside node_modules/@adafruit/circuitpython-repl-js/ does still say 2.0.1 after this, so I think that is unrelated or at least not the cause of my prior issues.

@makermelissa
Copy link
Collaborator Author

makermelissa commented Feb 4, 2025

Ok, I don't think I tested selected folder downloading, so I'll take a look.

@makermelissa
Copy link
Collaborator Author

It seems like every time I fix one thing another thing breaks. I'm getting close to finishing and realized there are 5 different test cases that need to all be working:

  • Single file selected
  • Root Folder (no files selected)
  • Sub Folder (no files selected)
  • Subfolder Selected
  • Multiple Files Selected

@makermelissa
Copy link
Collaborator Author

Ok, lots of testing later, it should all be working now. I ended up rewriting a lot of it and it makes a lot more sense now.

Copy link

@FoamyGuy FoamyGuy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested this locally with a Sparkle motion mini. Downloading a single file, a folder, and the entire drive are all working correctly for me now.

Selecting multiple files and then pressing download did download a zip but the files inside were 0 bytes. However I didn't realize that was intended to be supported, so I see it as a bonus if it does ultimately work.

Another thing that might be nice to have ultimately is more specific status during the downloading, if it can show each filename as it's working on them it will help assure the user that "it's working" and not stalled.

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.

2 participants