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

improve download, allow download of big files, works on ff and chrome #5466

Merged
merged 2 commits into from
Jul 12, 2019

Conversation

kittaakos
Copy link
Contributor

This is the follow-up of #4890

This PR improves the download by letting the native browser handle it
instead of fetching it in the background. This also adds a unique link
which expires in 1 minute. Tested on chrome 73.0 and
firefox 60.5

Signed-off-by: Uni Sayo unibtc@gmail.com

@kittaakos
Copy link
Contributor Author

I have tried it in Gitpod:

  • I could download a file,
  • multiple ones and folders (packed into a .tar),
  • download while another download was in progress,
  • also, I could download the entire Theia workspace without blocking the UI or experiencing offline on the status bar.
  • The Copy Download Link worked as well.

@svenefftinge, please review/approve. I am not allowed to do it for a PR with my own changes. Thanks!

@kittaakos kittaakos requested a review from svenefftinge June 14, 2019 10:25
Copy link
Member

@akosyakov akosyakov left a comment

Choose a reason for hiding this comment

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

It's strange that i have to press download twice to download.

Do we really need Copy Download Link? If so i would prefer to have a separate menu item. If i suppose to share it 1m timeout seems to be really small.

@akosyakov
Copy link
Member

Generally that's really good, UI is not blocked at all during preparing download.

@kittaakos
Copy link
Contributor Author

Do we really need Copy Download Link? If so i would prefer to have a separate menu item. If i suppose to share it 1m timeout seems to be really small.

From @uniibu:

And lastly, to be able to use a separate downloader, you will need the download link, so I added a Copy Download Link menu option which works for singe and multiple(tar) files/folders

@kittaakos
Copy link
Contributor Author

It's strange that i have to press download twice to download.

I did not experience this when I was updating the PR, so I have retested it again; it works. (Tried in Chrome and FF with Gitpod.)

@akosyakov
Copy link
Member

@kittaakos I meant that i have to click Download in the navigator and then in the notification again. For a single file it does not make sense. I'm not sure whether notification makes sense at all, we could simply start downloading and a user can cancel it via the browser.

@akosyakov akosyakov added the filesystem issues related to the filesystem label Jul 5, 2019
@uniibu
Copy link
Contributor

uniibu commented Jul 5, 2019

Do we really need Copy Download Link? If so i would prefer to have a separate menu item. If i suppose to share it 1m timeout seems to be really small.

From @uniibu:

And lastly, to be able to use a separate downloader, you will need the download link, so I added a Copy Download Link menu option which works for singe and multiple(tar) files/folders

Hi! Its been awhile.. Just want to be clear that, If my memory serves me right, the Download Link acts like a temporary url shortener so you can use it to download big files in parallel using 3rd party downloader and is not meant to be used for sharing. IMO, the 1 minute expiry should be enough for someone to copy it and paste it on their downloader. Even if the link expires as long as the download is already started, it will not be interrupted.

@kittaakos
Copy link
Contributor Author

use it to download big files in parallel using 3rd party downloader

👍 This. Thank you for the clarification.

@akosyakov
Copy link
Member

But a special case should not harm the standard scenario? Is it good that a user has to click twice and see notification for a single file?

As for Copy Download Link should not it be a separate menu item and then you immediately get a link which you paste somewhere?

This PR improves the download by letting the native browser handle it
instead of fetching it in the background. This also adds a unique link
which expires in 1 minute. Tested on chrome 73.0 and
firefox 60.5

Signed-off-by: Uni Sayo <unibtc@gmail.com>
@kittaakos
Copy link
Contributor Author

I have made the following changes:

  • From now on there are two separate commands: Download and Copy Download Link.
  • Download remains in the 6_downloadupload menu group.
  • Copy Download Link has been added to the Edit > 2_clipboard main menu group, and to the 5_cutcopypaste group for the Navigator context menu.
  • When Download is selected, the download will start automatically right after the prepare phase. Neither further user interaction is required, nor the user will be notified.
  • When Copy Download Link is selected, the link will be copied to the clipboard.

Screen Shot 2019-07-10 at 11 28 01
Screen Shot 2019-07-10 at 11 28 08
Screen Shot 2019-07-10 at 11 28 13

@kittaakos
Copy link
Contributor Author

  • Copy download link does not always work on FF.
  • If it works, it does not copy the link to the clipboard. I do not know if that was the case before my changes. I have to check.

@kittaakos
Copy link
Contributor Author

kittaakos commented Jul 10, 2019

  • Copy download link does not always work on FF.

The notification is discarded immediately, it is hard to see for small file(s).
But the link is not copied to the clipboard.

document.execCommand(‘cut’/‘copy’) was denied because it was not called from inside a short running user-generated event handler.

@kittaakos
Copy link
Contributor Author

I do not know how the copy/paste works in FF, but it seems, it is entirely unsupported the way we do: https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/Interact_with_the_clipboard

@kittaakos
Copy link
Contributor Author

kittaakos commented Jul 10, 2019

Updating the copy/paste functionality is not straightforward, as we do not have type definitions with the current typescript@3.1.3 version. However, it is already available within the most recent TypeScript.
See here: https://github.com/microsoft/TypeScript/blob/a4cddd4647154550fe603ec2b65a93cf8b2099dd/lib/lib.dom.d.ts#L10509

@kittaakos
Copy link
Contributor Author

So it seems, in FF one has to actually click on a button to invoke the clipboard-copy, I am going to disable it if the browser is not Chrome.

@kittaakos
Copy link
Contributor Author

PoC: https://jsfiddle.net/kittaakos/ru18g04p/
It works in Chrome but not in FF. One has to remove display: none and type into the input, lose the focus and see the the text from the input was not copied to the clipboard.

From now on, either the download link can
be copied to the clipboard or the download
can be triggered without any further user
interaction.

Note: `Copy Download Link` works in Chrome
only. #5466 (comment)

Signed-off-by: Akos Kitta <kittaakos@typefox.io>
@kittaakos
Copy link
Contributor Author

Ready for the review.

Copy link
Member

@akosyakov akosyakov left a comment

Choose a reason for hiding this comment

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

Download worked smooth, without double clicking. 👍

Copy download link worked but was confusing that a link is only in the clipboard after download is prepared. Would be better to pregenerate a link and give it immediately. Otherwise on big downloads it looks broken first time.

I'm going to approve it since it don't care much about Copy Download Link right now. Someone can improve it later.

@kittaakos kittaakos merged commit b2fbe6e into master Jul 12, 2019
@kittaakos kittaakos deleted the download-big branch July 12, 2019 09:25
@kittaakos
Copy link
Contributor Author

Thank you for your help, @uniibu 🥇

@502647092
Copy link
Contributor

@kittaakos @akosyakov
Copy Download Link Break Ctrl + C on edit
temp

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

Successfully merging this pull request may close these issues.

4 participants