-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
GH-1905: Implemented the file download functionality. #2114
Conversation
It is ready for the review. |
4e1c3f1
to
d567576
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could move most of this to filesystem. The context menu registration could be moved to navigator.
/** | ||
* `true` if the argument is an empty object. Otherwise, `false`. | ||
*/ | ||
export function isEmpty(arg: Object): boolean { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we also need to check the constructor : arg.constructor === Object
as in theory there can be other objects without own properties.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
@injectable() | ||
export class FileDownloadEndpoint implements BackendApplicationContribution { | ||
|
||
protected static PATH = '/file-download'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be just files
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
if (uris.length === 1) { | ||
return true; | ||
} | ||
// Can download multiple files iff they are from the same container folder. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why restrict it like that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am OK removing the restriction if you could help me define a clear way how the files should be zipped up in a folder when selecting multiple files "randomly" from a workspace.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could preserve the structure and use the common parent of all files as the container.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had the same idea, then I thought; we have to overcomplicate the backend logic for a feature which we won't use that frequently anyway, but let's do.
I did not want to. I think it is nice to have it in its extension. It is always easier to customize and put together an application from tiny extensions than registering my own sub-classes, override methods here and there and then rebind then for instance, when I want to disable/change the default functionality. But I could move it to the WS and FS. |
I would prefer it. Each extension adds a lot of infrastructural overhead (and degrades build performance) so it needs to be balanced when we create a new extension. I think in this case it tends towards having it in file-system as it is an endpoint exposing it. |
It is unfortunate, we have to define extensions and adapt the code to this, but I see your point. |
Also, could we use tar instead of zip? |
What can I do with a tar as a Windows user? I am just asking... I am not aware of any built-in tools that unpack the tar on Windows. Is it a good idea to force users to use 7Zip? |
@kittaakos did you see the build failures? |
Thanks for the note: no. I am still in the middle of the changes; the commits are not yet squashed... I will ping you here when it is ready for the review. |
@svenefftinge, I have made a few changes regarding the multi-file download feature; I would consider this PR ready for review. |
Downloading a directory (e.g. packages in theia repo) is still taking far too long to go without any kind of user feedback. We should at least add an item to the statusbar : |
OK. |
I did some measurements, and the bottleneck is the archiving part: this takes 29430 ms when downloading the |
I have managed to pipe the |
This is done. |
I tried to fine-tune the status bar's This could be the root of the defect (source: whatwg/html#954 (comment)): |
Closes #1905. Signed-off-by: Akos Kitta <kittaakos@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
Is there a flow diagram somewhere in order to understand how download a file/folder programmatically? |
No, there isn't. At least, I am not aware of it.
Check this thread. It might be outdated, though. If it does not work now, please open a follow-up issue, or start a discussion, to attract more attention for your problem. This is a closed PR. I hope this helps. |
Closes #1905.
Signed-off-by: Akos Kitta kittaakos@gmail.com