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

feat: use direct links to download all files #1894

Merged
merged 7 commits into from
Nov 22, 2022
Merged

feat: use direct links to download all files #1894

merged 7 commits into from
Nov 22, 2022

Conversation

hacdias
Copy link
Member

@hacdias hacdias commented Jan 16, 2022

This closes #1887 by using the gateway URLs to download the files. There's two things to mention:

  1. I tried creating an anchor element to download the file with a name via the download attribute, but it seems to still use the name get.tar.gz sadly. Any suggestions?
  2. There's some other code that used to show download progress. Should I remove it? I don't think it is used anywhere else in the code so it feels safe to remove unless it can be used for any planned feature.

License: MIT
Signed-off-by: Henrique Dias hacdias@gmail.com

@hacdias hacdias requested a review from lidel January 16, 2022 20:20
@hacdias hacdias temporarily deployed to Deploy January 16, 2022 20:25 Inactive
Copy link
Member

@lidel lidel left a comment

Choose a reason for hiding this comment

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

Re 1 – see inline comment
Re 2 – ok to remove the dowload-file.js, do you have something more in mind?

src/files/FilesPage.js Outdated Show resolved Hide resolved
@lidel lidel added the status/blocked Unable to be worked further until needs are met label Jan 18, 2022
@hacdias hacdias temporarily deployed to Deploy June 2, 2022 09:15 Inactive
@lidel lidel force-pushed the main branch 4 times, most recently from dabaee3 to 7ddf870 Compare June 29, 2022 22:19
@hacdias hacdias removed the status/blocked Unable to be worked further until needs are met label Nov 10, 2022
@hacdias
Copy link
Member Author

hacdias commented Nov 10, 2022

The TARs are a thing on the gateway now: ipfs/kubo#9029

This PR can be unblocked and worked on 😃

License: MIT
Signed-off-by: Henrique Dias <hacdias@gmail.com>
@hacdias hacdias requested a review from lidel November 10, 2022 13:28
@hacdias hacdias changed the title fix: use direct link to gateway to download files feat: use direct links to download all files Nov 10, 2022
@hacdias hacdias temporarily deployed to Deploy November 10, 2022 13:36 Inactive
@hacdias hacdias self-assigned this Nov 10, 2022
@hacdias
Copy link
Member Author

hacdias commented Nov 10, 2022

I decided to revitalise this PR since we now have TAR response formats on our gateway (ipfs/kubo#9029). That lets us download directories directly from the gateway without the need to use the API v0 POST method. Therefore, we do not need to keep anything in memory and it is all streamed to the user. This allows to massively simplify the code, removing a lot of old bits that are no longer relevant 🪩

This can be tested with Kubo from master, and with 0.17.0 RC-1. I'll mark this as ready for review as its been open for many months, but it's finally possible to review and test this PR.

@hacdias hacdias marked this pull request as ready for review November 10, 2022 13:41
@hacdias hacdias requested a review from a team as a code owner November 10, 2022 13:41
Copy link
Member

@lidel lidel left a comment

Choose a reason for hiding this comment

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

lgtm, small UX question below

src/lib/files.js Show resolved Hide resolved
Copy link
Member

@SgtPooki SgtPooki left a comment

Choose a reason for hiding this comment

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

The changes look okay, but we're removing some functionality: progress updates and download aborting. Is that intended, or am I missing something?

Note: I do agree that this is a significant improvement, and resolves #1887 but I'm wondering if there is a way we can keep the ability to cancel a download, or display download progress. Fine with a separate issue for those items

Comment on lines 58 to 61
const url = await doFilesDownloadLink(files)
const link = document.createElement('a')
link.href = url
link.click()
Copy link
Member

Choose a reason for hiding this comment

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

non-blocking Q: instead of creating an element and then programmatically clicking on it can we have the thing the users click have the appropriate URL?

Copy link
Member Author

Choose a reason for hiding this comment

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

Note: I do agree that this is a significant improvement, and resolves #1887 but I'm wondering if there is a way we can keep the ability to cancel a download, or display download progress. Fine with a separate issue for those items

Downloads will be handled by the browser UI. The user can just cancel it through the browser UI. We only had the option to cancel and display progress on the Web UI itself because we were storing every single byte of data in-memory before downloading.

Copy link
Member Author

@hacdias hacdias Nov 10, 2022

Choose a reason for hiding this comment

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

non-blocking Q: instead of creating an element and then programmatically clicking on it can we have the thing the users click have the appropriate URL?

Yes and no. If you select multiple files, what link do you put? You can't as we calculate the CID dynamically. Then we'd need different behaviour according to the number of files selected and that's a bit of a hassle. Let's keep it like this to be uniform with the CAR downloading behaviour.

Copy link
Contributor

Choose a reason for hiding this comment

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

Can't we just redirect the users to download? it will prompt the user to download and not go away from current page too?

Copy link
Member Author

@hacdias hacdias Nov 11, 2022

Choose a reason for hiding this comment

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

@whizzzkid I changed to window.location.href = url. However, it has the same behaviour in my browser as clicking a link. Because clicking a link just leads to redirection. I'm interested in knowing what is happening in your browser, because I can't understand. I'll post a video here in a bit (see #1894 (comment)).

Copy link
Contributor

@whizzzkid whizzzkid left a comment

Choose a reason for hiding this comment

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

non-blocking nits

src/bundles/files/actions.js Outdated Show resolved Hide resolved
Comment on lines 58 to 61
const url = await doFilesDownloadLink(files)
const link = document.createElement('a')
link.href = url
link.click()
Copy link
Contributor

Choose a reason for hiding this comment

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

Can't we just redirect the users to download? it will prompt the user to download and not go away from current page too?

render () {
const { t, tReady, animateOnStart, count, size, unselect, remove, share, setPinning, download, downloadProgress, rename, inspect, className, style, isMfs, ...props } = this.props
const { t, tReady, animateOnStart, count, size, unselect, remove, share, setPinning, download, rename, inspect, className, style, isMfs, ...props } = this.props
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we sort these alphabetically?

Copy link
Member Author

Choose a reason for hiding this comment

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

Unless you know how to do it automatically, please don't make me do it 😅

Copy link
Member

Choose a reason for hiding this comment

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

eslint can do it automatically, we should not be forcing devs to do code style management

@hacdias hacdias temporarily deployed to Deploy November 11, 2022 10:07 Inactive
@hacdias
Copy link
Member Author

hacdias commented Nov 11, 2022

@SgtPooki @whizzzkid I addressed most of your comments (see replies). This is the behaviour of the current PR:

cast.mp4

Copy link
Member

@SgtPooki SgtPooki left a comment

Choose a reason for hiding this comment

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

Thanks a ton for remembering this PR and coming back to close it out @hacdias !

@SgtPooki
Copy link
Member

Do we expect any issues with how this will work within electron?

@hacdias
Copy link
Member Author

hacdias commented Nov 14, 2022

Do we expect any issues with how this will work within electron?

I think it should be fine. We already had download links we this behaviour before and they were not a problem.

@SgtPooki SgtPooki merged commit d1bcbbf into main Nov 22, 2022
@SgtPooki SgtPooki deleted the fix/1887 branch November 22, 2022 18:35
ipfs-gui-bot pushed a commit that referenced this pull request Dec 9, 2022
## [2.21.0](v2.20.0...v2.21.0) (2022-12-09)

 CID `bafybeiequgo72mrvuml56j4gk7crewig5bavumrrzhkqbim6b3s2yqi7ty`

 ---

### Features

* use direct links to download all files ([#1894](#1894)) ([d1bcbbf](d1bcbbf))

### Bug Fixes

* support /quic-v1 ([#2073](#2073)) ([04eb7b3](04eb7b3))

### Trivial Changes

* bump playwright deps ([#2066](#2066)) ([f138960](f138960))
* **ci:** fix flaky unit test ([#2068](#2068)) ([bd038cd](bd038cd)), closes [/github.com//issues/2065#issuecomment-1315933342](https://github.com/ipfs//github.com/ipfs/ipfs-webui/issues/2065/issues/issuecomment-1315933342)
* Pull transifex translations ([#2069](#2069)) ([36f3641](36f3641))
* revert [#2032](#2032) ([#2064](#2064)) ([9473d7d](9473d7d)), closes [/github.com//pull/2032#issuecomment-1278928440](https://github.com/ipfs//github.com/ipfs/ipfs-webui/pull/2032/issues/issuecomment-1278928440)
@ipfs-gui-bot
Copy link
Collaborator

🎉 This PR is included in version 2.21.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
No open projects
Archived in project
Archived in project
Development

Successfully merging this pull request may close these issues.

File → menu → Download buffers entire file into a blob
6 participants