-
Notifications
You must be signed in to change notification settings - Fork 5.7k
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: add option for disabling file downloads #5055
Conversation
✨ code-server docs for PR #5055 is ready! It will be updated on every commit.
|
Codecov Report
@@ Coverage Diff @@
## main #5055 +/- ##
==========================================
+ Coverage 71.30% 71.33% +0.03%
==========================================
Files 30 30
Lines 1683 1685 +2
Branches 373 374 +1
==========================================
+ Hits 1200 1202 +2
Misses 413 413
Partials 70 70
Continue to review full report at Codecov.
|
22859c7
to
f7c6000
Compare
53a14d5
to
dd9a2c3
Compare
Co-authored-by: Asher <[email protected]>
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.
Looks great!
I am not sure if we should try this now or if this is good enough but we might want to disable the download command itself because it is possible to bind the download command to a keybinding and then just use that to download files.
* feat(cli): add disable-file-downloads to cli * feat(e2e): add download test * feat(e2e): add downloads disabled test * refactor(e2e): explain how to debug unexpected close * feat(patches): add disable file downloads * wip: update diff * Update src/node/cli.ts Co-authored-by: Asher <[email protected]> * fixup! add missing common/contextkeys file to patch * fixup!: update patch * fixup!: default disable-file-downloads undefined * fixup!: combine e2e tests * fixup!: use different test names * feat: add CS_DISABLE_FILE_DOWNLOADS * fixup!: make explicit and cleanup test * fixup!: use beforeEach Co-authored-by: Asher <[email protected]>
This PR adds a new CLI flag called
--disable-file-downloads
which removes the "Download..." option from the File Actions (right-clicking on file).Screenshot
As you can see, there is no "Download..." option here:
e2e test ensuring the behavior works as well.
e2e test ensuring default behavior (downloads enabled) works:
Fixes #2426
Notes
Click to expand
What is the current behavior?
Currently, the default behavior is to allow any file to be downloaded (note: not folders). To do this,
What is the desired behavior?
A way to disable this behavior.
The best solution we've come up with is a CLI option such as
--disable-file-downloads
which would be a boolean flag meaning the default is false, but when you pass it, it is true. You could also explicitly say--disable-file-downloads=true
. And because of the way code-server is designed, you'll also be able to set it in yourconfig.yaml
likedisable-file-downloads: true
.How do we implement this?
There are two pieces of logic to implement:
--disable-file-downloads
true
For 1, we can take a TDD approach and write a test to ensure that:
--disable-file-downloads
flag--disable-file-downlaods=true
For 2, we can take TDD but it's a little bit more work:
fileActions.contributions.ts
disable-file-downloads
as arg toserverEnvironmentService
To do this, I need to create a new context key like this then add it here
Running e2e tests:
VSCODE_DEV=1 LOG_LEVEL=debug yarn test:e2e --grep "disabled" --quiet --retries 0 --debug
Seeing these type errors:
Now it's not working 🤔