2023-12-08 05:10:22 +08:00
Add option to disable file downloads and uploads via cli
2022-04-14 00:39:05 +08:00
This patch adds support for a new CLI flag called `--disable-file-downloads`
which allows a user to remove the "Download..." option that shows up when you
2023-12-08 05:10:22 +08:00
right-click files in Code. It also disables the "Show Local" button on the dialog
for Save, Save-As and Save Workspace. The default value for this is `false`.
2022-04-14 00:39:05 +08:00
2023-12-08 05:10:22 +08:00
This patch also add support for a new CLI flag called `--disable-file-uploads`
which disables the drag to upload functionality and the "Upload..." option when you
right-click folders in Code. It also disables the "Show Local" button on the dialog
for opening a file. The default value for this is `false`.
This patch also adds trace log statements for when a file is read and written to disk.
To test disabling downloads, start code-server with `--disable-file-downloads`, open editor,
2022-04-14 00:39:05 +08:00
right-click on a file (not a folder) and you should **not** see the
2023-12-08 05:10:22 +08:00
"Download..." option. When saving a file or workspace, the "Show Local" button
should **not** appear on the dialog that comes on screen.
To test disabling uploads, start code-server with `--disable-file-uploads`, open editor,
right-click on a folder (not a file) and you should **not** see the
"Upload..." option. If you drag a file into the file navigator, the file should **not** upload
and appear in the file navigator. When opening a file, the "Show Local" button
should **not** appear on the dialog that comes on screen.
2022-04-14 00:39:05 +08:00
Index: code-server/lib/vscode/src/vs/workbench/browser/web.api.ts
===================================================================
--- code-server.orig/lib/vscode/src/vs/workbench/browser/web.api.ts
+++ code-server/lib/vscode/src/vs/workbench/browser/web.api.ts
2024-05-07 06:14:53 +08:00
@@ -303,6 +303,16 @@ export interface IWorkbenchConstructionO
2022-04-14 00:39:05 +08:00
*/
2023-11-28 10:03:22 +08:00
readonly userDataPath?: string
2022-04-14 00:39:05 +08:00
+ /**
+ * Whether the "Download..." option is enabled for files.
+ */
+ readonly isEnabledFileDownloads?: boolean
2023-12-08 05:10:22 +08:00
+
+ /**
+ * Whether the "Upload..." button is enabled.
+ */
+ readonly isEnabledFileUploads?: boolean
2022-04-14 00:39:05 +08:00
+
//#endregion
2023-02-08 06:22:06 +08:00
//#region Profile options
2022-04-14 00:39:05 +08:00
Index: code-server/lib/vscode/src/vs/workbench/services/environment/browser/environmentService.ts
===================================================================
--- code-server.orig/lib/vscode/src/vs/workbench/services/environment/browser/environmentService.ts
+++ code-server/lib/vscode/src/vs/workbench/services/environment/browser/environmentService.ts
2023-12-08 05:10:22 +08:00
@@ -34,6 +34,16 @@ export interface IBrowserWorkbenchEnviro
2022-04-14 00:39:05 +08:00
readonly options?: IWorkbenchConstructionOptions;
2023-06-16 00:00:03 +08:00
/**
2022-04-14 00:39:05 +08:00
+ * Enable downloading files via menu actions.
+ */
+ readonly isEnabledFileDownloads?: boolean;
2023-06-16 00:00:03 +08:00
+
2023-12-08 05:10:22 +08:00
+ /**
+ * Enable uploading files via menu actions.
+ */
+ readonly isEnabledFileUploads?: boolean;
+
2023-06-16 00:00:03 +08:00
+ /**
* Gets whether a resolver extension is expected for the environment.
*/
readonly expectsResolverExtension: boolean;
2023-12-08 05:10:22 +08:00
@@ -111,6 +121,20 @@ export class BrowserWorkbenchEnvironment
2023-11-28 10:03:22 +08:00
return this.options.userDataPath;
}
2022-04-14 00:39:05 +08:00
+ get isEnabledFileDownloads(): boolean {
+ if (typeof this.options.isEnabledFileDownloads === "undefined") {
+ throw new Error('isEnabledFileDownloads was not provided to the browser');
+ }
+ return this.options.isEnabledFileDownloads;
+ }
2023-12-08 05:10:22 +08:00
+
+ get isEnabledFileUploads(): boolean {
+ if (typeof this.options.isEnabledFileUploads === "undefined") {
+ throw new Error('isEnabledFileUploads was not provided to the browser');
+ }
+ return this.options.isEnabledFileUploads;
+ }
2022-04-14 00:39:05 +08:00
+
@memoize
2023-11-28 10:03:22 +08:00
get argvResource(): URI { return joinPath(this.userRoamingDataHome, 'argv.json'); }
2022-04-14 00:39:05 +08:00
Index: code-server/lib/vscode/src/vs/server/node/serverEnvironmentService.ts
===================================================================
--- code-server.orig/lib/vscode/src/vs/server/node/serverEnvironmentService.ts
+++ code-server/lib/vscode/src/vs/server/node/serverEnvironmentService.ts
2023-12-08 05:10:22 +08:00
@@ -16,6 +16,8 @@ export const serverOptions: OptionDescri
2022-06-22 05:51:46 +08:00
/* ----- code-server ----- */
2022-04-14 00:39:05 +08:00
'disable-update-check': { type: 'boolean' },
'auth': { type: 'string' },
+ 'disable-file-downloads': { type: 'boolean' },
2023-12-08 05:10:22 +08:00
+ 'disable-file-uploads': { type: 'boolean' },
2022-04-14 00:39:05 +08:00
/* ----- server setup ----- */
2024-04-06 06:20:28 +08:00
@@ -99,6 +101,8 @@ export interface ServerParsedArgs {
2022-06-22 05:51:46 +08:00
/* ----- code-server ----- */
2022-04-14 00:39:05 +08:00
'disable-update-check'?: boolean;
2024-05-07 08:31:33 +08:00
'auth'?: string;
2022-04-14 00:39:05 +08:00
+ 'disable-file-downloads'?: boolean;
2023-12-08 05:10:22 +08:00
+ 'disable-file-uploads'?: boolean;
2022-04-14 00:39:05 +08:00
/* ----- server setup ----- */
Index: code-server/lib/vscode/src/vs/server/node/webClientServer.ts
===================================================================
--- code-server.orig/lib/vscode/src/vs/server/node/webClientServer.ts
+++ code-server/lib/vscode/src/vs/server/node/webClientServer.ts
2024-04-06 06:20:28 +08:00
@@ -334,6 +334,8 @@ export class WebClientServer {
serverBasePath: this._basePath,
2022-06-22 05:51:46 +08:00
webviewEndpoint: vscodeBase + this._staticRoute + '/out/vs/workbench/contrib/webview/browser/pre',
2023-11-28 10:03:22 +08:00
userDataPath: this._environmentService.userDataPath,
2022-06-22 05:51:46 +08:00
+ isEnabledFileDownloads: !this._environmentService.args['disable-file-downloads'],
2023-12-08 05:10:22 +08:00
+ isEnabledFileUploads: !this._environmentService.args['disable-file-uploads'],
2022-06-22 05:51:46 +08:00
_wrapWebWorkerExtHostInIframe,
2022-10-18 07:30:39 +08:00
developmentOptions: { enableSmokeTestDriver: this._environmentService.args['enable-smoke-test-driver'] ? true : undefined, logLevel: this._logService.getLevel() },
settingsSyncOptions: !this._environmentService.isBuilt && this._environmentService.args['enable-sync'] ? { enabled: true } : undefined,
2022-04-14 00:39:05 +08:00
Index: code-server/lib/vscode/src/vs/workbench/browser/contextkeys.ts
===================================================================
--- code-server.orig/lib/vscode/src/vs/workbench/browser/contextkeys.ts
+++ code-server/lib/vscode/src/vs/workbench/browser/contextkeys.ts
2023-06-16 00:00:03 +08:00
@@ -7,12 +7,12 @@ import { Event } from 'vs/base/common/ev
2022-04-14 00:39:05 +08:00
import { Disposable } from 'vs/base/common/lifecycle';
2023-04-11 02:28:13 +08:00
import { IContextKeyService, IContextKey, setConstant as setConstantContextKey } from 'vs/platform/contextkey/common/contextkey';
2022-10-18 07:30:39 +08:00
import { InputFocusedContext, IsMacContext, IsLinuxContext, IsWindowsContext, IsWebContext, IsMacNativeContext, IsDevelopmentContext, IsIOSContext, ProductQualityContext, IsMobileContext } from 'vs/platform/contextkey/common/contextkeys';
2024-04-06 06:20:28 +08:00
-import { SplitEditorsVertically, InEditorZenModeContext, ActiveEditorCanRevertContext, ActiveEditorGroupLockedContext, ActiveEditorCanSplitInGroupContext, SideBySideEditorActiveContext, AuxiliaryBarVisibleContext, SideBarVisibleContext, PanelAlignmentContext, PanelMaximizedContext, PanelVisibleContext, ActiveEditorContext, EditorsVisibleContext, TextCompareEditorVisibleContext, TextCompareEditorActiveContext, ActiveEditorGroupEmptyContext, EmbedderIdentifierContext, EditorTabsVisibleContext, IsMainEditorCenteredLayoutContext, ActiveEditorGroupIndexContext, ActiveEditorGroupLastContext, ActiveEditorReadonlyContext, MainEditorAreaVisibleContext, ActiveEditorAvailableEditorIdsContext, DirtyWorkingCopiesContext, EmptyWorkspaceSupportContext, EnterMultiRootWorkspaceSupportContext, HasWebFileSystemAccess, IsMainWindowFullscreenContext, OpenFolderWorkspaceSupportContext, RemoteNameContext, VirtualWorkspaceContext, WorkbenchStateContext, WorkspaceFolderCountContext, PanelPositionContext, TemporaryWorkspaceContext, ActiveEditorCanToggleReadonlyContext, applyAvailableEditorIds, TitleBarVisibleContext, TitleBarStyleContext, MultipleEditorGroupsContext, IsAuxiliaryWindowFocusedContext, ActiveCompareEditorCanSwapContext } from 'vs/workbench/common/contextkeys';
+import { SplitEditorsVertically, InEditorZenModeContext, ActiveEditorCanRevertContext, ActiveEditorGroupLockedContext, ActiveEditorCanSplitInGroupContext, SideBySideEditorActiveContext, AuxiliaryBarVisibleContext, SideBarVisibleContext, PanelAlignmentContext, PanelMaximizedContext, PanelVisibleContext, ActiveEditorContext, EditorsVisibleContext, TextCompareEditorVisibleContext, TextCompareEditorActiveContext, ActiveEditorGroupEmptyContext, EmbedderIdentifierContext, EditorTabsVisibleContext, IsMainEditorCenteredLayoutContext, ActiveEditorGroupIndexContext, ActiveEditorGroupLastContext, ActiveEditorReadonlyContext, MainEditorAreaVisibleContext, ActiveEditorAvailableEditorIdsContext, DirtyWorkingCopiesContext, EmptyWorkspaceSupportContext, EnterMultiRootWorkspaceSupportContext, HasWebFileSystemAccess, IsMainWindowFullscreenContext, OpenFolderWorkspaceSupportContext, RemoteNameContext, VirtualWorkspaceContext, WorkbenchStateContext, WorkspaceFolderCountContext, PanelPositionContext, TemporaryWorkspaceContext, ActiveEditorCanToggleReadonlyContext, applyAvailableEditorIds, TitleBarVisibleContext, TitleBarStyleContext, MultipleEditorGroupsContext, IsAuxiliaryWindowFocusedContext, ActiveCompareEditorCanSwapContext, IsEnabledFileDownloads, IsEnabledFileUploads } from 'vs/workbench/common/contextkeys';
2023-09-21 07:33:28 +08:00
import { TEXT_DIFF_EDITOR_ID, EditorInputCapabilities, SIDE_BY_SIDE_EDITOR_ID, EditorResourceAccessor, SideBySideEditor } from 'vs/workbench/common/editor';
2023-12-16 05:38:01 +08:00
import { trackFocus, addDisposableListener, EventType, onDidRegisterWindow, getActiveWindow } from 'vs/base/browser/dom';
2022-04-14 00:39:05 +08:00
import { preferredSideBySideGroupDirection, GroupDirection, IEditorGroupsService } from 'vs/workbench/services/editor/common/editorGroupsService';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
-import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/common/environmentService';
2023-06-16 00:00:03 +08:00
+import { IBrowserWorkbenchEnvironmentService } from 'vs/workbench/services/environment/browser/environmentService';
2022-04-14 00:39:05 +08:00
import { IEditorService } from 'vs/workbench/services/editor/common/editorService';
2022-10-18 07:30:39 +08:00
import { WorkbenchState, IWorkspaceContextService, isTemporaryWorkspace } from 'vs/platform/workspace/common/workspace';
2022-04-14 00:39:05 +08:00
import { IWorkbenchLayoutService, Parts, positionToString } from 'vs/workbench/services/layout/browser/layoutService';
2024-04-06 06:20:28 +08:00
@@ -88,7 +88,7 @@ export class WorkbenchContextKeysHandler
2022-04-14 00:39:05 +08:00
@IContextKeyService private readonly contextKeyService: IContextKeyService,
@IWorkspaceContextService private readonly contextService: IWorkspaceContextService,
@IConfigurationService private readonly configurationService: IConfigurationService,
- @IWorkbenchEnvironmentService private readonly environmentService: IWorkbenchEnvironmentService,
+ @IBrowserWorkbenchEnvironmentService private readonly environmentService: IBrowserWorkbenchEnvironmentService,
2022-08-17 09:26:19 +08:00
@IProductService private readonly productService: IProductService,
2022-04-14 00:39:05 +08:00
@IEditorService private readonly editorService: IEditorService,
@IEditorResolverService private readonly editorResolverService: IEditorResolverService,
2024-04-06 06:20:28 +08:00
@@ -225,6 +225,10 @@ export class WorkbenchContextKeysHandler
2022-04-14 00:39:05 +08:00
this.auxiliaryBarVisibleContext = AuxiliaryBarVisibleContext.bindTo(this.contextKeyService);
this.auxiliaryBarVisibleContext.set(this.layoutService.isVisible(Parts.AUXILIARYBAR_PART));
+ // code-server
+ IsEnabledFileDownloads.bindTo(this.contextKeyService).set(this.environmentService.isEnabledFileDownloads ?? true)
2023-12-08 05:10:22 +08:00
+ IsEnabledFileUploads.bindTo(this.contextKeyService).set(this.environmentService.isEnabledFileUploads ?? true)
2022-04-14 00:39:05 +08:00
+
this.registerListeners();
}
Index: code-server/lib/vscode/src/vs/workbench/contrib/files/browser/fileActions.contribution.ts
===================================================================
--- code-server.orig/lib/vscode/src/vs/workbench/contrib/files/browser/fileActions.contribution.ts
+++ code-server/lib/vscode/src/vs/workbench/contrib/files/browser/fileActions.contribution.ts
2022-11-10 06:10:03 +08:00
@@ -20,7 +20,7 @@ import { CLOSE_SAVED_EDITORS_COMMAND_ID,
2022-04-14 00:39:05 +08:00
import { AutoSaveAfterShortDelayContext } from 'vs/workbench/services/filesConfiguration/common/filesConfigurationService';
import { WorkbenchListDoubleSelection } from 'vs/platform/list/browser/listService';
import { Schemas } from 'vs/base/common/network';
2022-11-10 06:10:03 +08:00
-import { DirtyWorkingCopiesContext, EnterMultiRootWorkspaceSupportContext, HasWebFileSystemAccess, WorkbenchStateContext, WorkspaceFolderCountContext, SidebarFocusContext, ActiveEditorCanRevertContext, ActiveEditorContext, ResourceContextKey, ActiveEditorAvailableEditorIdsContext } from 'vs/workbench/common/contextkeys';
2023-12-08 05:10:22 +08:00
+import { DirtyWorkingCopiesContext, EnterMultiRootWorkspaceSupportContext, HasWebFileSystemAccess, WorkbenchStateContext, WorkspaceFolderCountContext, SidebarFocusContext, ActiveEditorCanRevertContext, ActiveEditorContext, ResourceContextKey, ActiveEditorAvailableEditorIdsContext, IsEnabledFileDownloads, IsEnabledFileUploads } from 'vs/workbench/common/contextkeys';
2022-04-14 00:39:05 +08:00
import { IsWebContext } from 'vs/platform/contextkey/common/contextkeys';
import { ServicesAccessor } from 'vs/platform/instantiation/common/instantiation';
2023-02-08 06:22:06 +08:00
import { ThemeIcon } from 'vs/base/common/themables';
2024-05-07 06:14:53 +08:00
@@ -553,13 +553,16 @@ MenuRegistry.appendMenuItem(MenuId.Explo
2022-04-14 00:39:05 +08:00
id: DOWNLOAD_COMMAND_ID,
title: DOWNLOAD_LABEL
},
- when: ContextKeyExpr.or(
- // native: for any remote resource
- ContextKeyExpr.and(IsWebContext.toNegated(), ResourceContextKey.Scheme.notEqualsTo(Schemas.file)),
- // web: for any files
- ContextKeyExpr.and(IsWebContext, ExplorerFolderContext.toNegated(), ExplorerRootContext.toNegated()),
- // web: for any folders if file system API support is provided
- ContextKeyExpr.and(IsWebContext, HasWebFileSystemAccess)
+ when: ContextKeyExpr.and(
+ IsEnabledFileDownloads,
+ ContextKeyExpr.or(
+ // native: for any remote resource
+ ContextKeyExpr.and(IsWebContext.toNegated(), ResourceContextKey.Scheme.notEqualsTo(Schemas.file)),
+ // web: for any files
+ ContextKeyExpr.and(IsWebContext, ExplorerFolderContext.toNegated(), ExplorerRootContext.toNegated()),
+ // web: for any folders if file system API support is provided
+ ContextKeyExpr.and(IsWebContext, HasWebFileSystemAccess)
+ )
)
}));
2024-05-07 06:14:53 +08:00
@@ -571,6 +574,7 @@ MenuRegistry.appendMenuItem(MenuId.Explo
2023-12-08 05:10:22 +08:00
title: UPLOAD_LABEL,
},
when: ContextKeyExpr.and(
+ IsEnabledFileUploads,
// only in web
IsWebContext,
// only on folders
2022-04-14 00:39:05 +08:00
Index: code-server/lib/vscode/src/vs/workbench/common/contextkeys.ts
===================================================================
--- code-server.orig/lib/vscode/src/vs/workbench/common/contextkeys.ts
+++ code-server/lib/vscode/src/vs/workbench/common/contextkeys.ts
2023-12-16 05:38:01 +08:00
@@ -40,6 +40,9 @@ export const HasWebFileSystemAccess = ne
2022-04-14 00:39:05 +08:00
2023-04-11 02:28:13 +08:00
export const EmbedderIdentifierContext = new RawContextKey<string | undefined>('embedderIdentifier', undefined, localize('embedderIdentifier', 'The identifier of the embedder according to the product service, if one is defined'));
2022-04-14 00:39:05 +08:00
+export const IsEnabledFileDownloads = new RawContextKey<boolean>('isEnabledFileDownloads', true, true);
2023-12-08 05:10:22 +08:00
+export const IsEnabledFileUploads = new RawContextKey<boolean>('isEnabledFileUploads', true, true);
2022-04-14 00:39:05 +08:00
+
//#endregion
2023-12-08 05:10:22 +08:00
Index: code-server/lib/vscode/src/vs/workbench/services/dialogs/browser/simpleFileDialog.ts
===================================================================
--- code-server.orig/lib/vscode/src/vs/workbench/services/dialogs/browser/simpleFileDialog.ts
+++ code-server/lib/vscode/src/vs/workbench/services/dialogs/browser/simpleFileDialog.ts
@@ -18,7 +18,7 @@ import { IModelService } from 'vs/editor
import { ILanguageService } from 'vs/editor/common/languages/language';
import { getIconClasses } from 'vs/editor/common/services/getIconClasses';
import { Schemas } from 'vs/base/common/network';
-import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/common/environmentService';
+import { IBrowserWorkbenchEnvironmentService } from 'vs/workbench/services/environment/browser/environmentService';
import { IRemoteAgentService } from 'vs/workbench/services/remote/common/remoteAgentService';
import { IContextKeyService, IContextKey, RawContextKey } from 'vs/platform/contextkey/common/contextkey';
import { equalsIgnoreCase, format, startsWithIgnoreCase } from 'vs/base/common/strings';
2023-12-16 05:38:01 +08:00
@@ -143,7 +143,7 @@ export class SimpleFileDialog implements
2023-12-08 05:10:22 +08:00
@IFileDialogService private readonly fileDialogService: IFileDialogService,
@IModelService private readonly modelService: IModelService,
@ILanguageService private readonly languageService: ILanguageService,
- @IWorkbenchEnvironmentService protected readonly environmentService: IWorkbenchEnvironmentService,
+ @IBrowserWorkbenchEnvironmentService protected readonly environmentService: IBrowserWorkbenchEnvironmentService,
@IRemoteAgentService private readonly remoteAgentService: IRemoteAgentService,
@IPathService protected readonly pathService: IPathService,
@IKeybindingService private readonly keybindingService: IKeybindingService,
2024-02-02 09:36:47 +08:00
@@ -286,20 +286,22 @@ export class SimpleFileDialog implements
this.filePickBox.sortByLabel = false;
2023-12-08 05:10:22 +08:00
this.filePickBox.ignoreFocusOut = true;
this.filePickBox.ok = true;
- if ((this.scheme !== Schemas.file) && this.options && this.options.availableFileSystems && (this.options.availableFileSystems.length > 1) && (this.options.availableFileSystems.indexOf(Schemas.file) > -1)) {
- this.filePickBox.customButton = true;
- this.filePickBox.customLabel = nls.localize('remoteFileDialog.local', 'Show Local');
- let action;
- if (isSave) {
- action = SaveLocalFileCommand;
- } else {
- action = this.allowFileSelection ? (this.allowFolderSelection ? OpenLocalFileFolderCommand : OpenLocalFileCommand) : OpenLocalFolderCommand;
- }
- const keybinding = this.keybindingService.lookupKeybinding(action.ID);
- if (keybinding) {
- const label = keybinding.getLabel();
- if (label) {
- this.filePickBox.customHover = format('{0} ({1})', action.LABEL, label);
+ if ((isSave && this.environmentService.isEnabledFileDownloads) || (!isSave && this.environmentService.isEnabledFileUploads)) {
+ if ((this.scheme !== Schemas.file) && this.options && this.options.availableFileSystems && (this.options.availableFileSystems.length > 1) && (this.options.availableFileSystems.indexOf(Schemas.file) > -1)) {
+ this.filePickBox.customButton = true;
+ this.filePickBox.customLabel = nls.localize('remoteFileDialog.local', 'Show Local');
+ let action;
+ if (isSave) {
+ action = SaveLocalFileCommand;
+ } else {
+ action = this.allowFileSelection ? (this.allowFolderSelection ? OpenLocalFileFolderCommand : OpenLocalFileCommand) : OpenLocalFolderCommand;
+ }
+ const keybinding = this.keybindingService.lookupKeybinding(action.ID);
+ if (keybinding) {
+ const label = keybinding.getLabel();
+ if (label) {
+ this.filePickBox.customHover = format('{0} ({1})', action.LABEL, label);
+ }
}
}
}
Index: code-server/lib/vscode/src/vs/workbench/contrib/files/browser/views/explorerViewer.ts
===================================================================
--- code-server.orig/lib/vscode/src/vs/workbench/contrib/files/browser/views/explorerViewer.ts
+++ code-server/lib/vscode/src/vs/workbench/contrib/files/browser/views/explorerViewer.ts
2023-12-16 05:38:01 +08:00
@@ -68,6 +68,7 @@ import { HoverPosition } from 'vs/base/b
2023-12-08 05:10:22 +08:00
import { IFilesConfigurationService } from 'vs/workbench/services/filesConfiguration/common/filesConfigurationService';
2023-12-16 05:38:01 +08:00
import { mainWindow } from 'vs/base/browser/window';
import { IExplorerFileContribution, explorerFileContribRegistry } from 'vs/workbench/contrib/files/browser/explorerFileContrib';
2023-12-08 05:10:22 +08:00
+import { IBrowserWorkbenchEnvironmentService } from 'vs/workbench/services/environment/browser/environmentService';
2024-05-07 06:14:53 +08:00
import type { IHoverWidget } from 'vs/base/browser/ui/hover/hover';
2023-12-08 05:10:22 +08:00
export class ExplorerDelegate implements IListVirtualDelegate<ExplorerItem> {
2024-04-06 06:20:28 +08:00
@@ -1080,7 +1081,8 @@ export class FileDragAndDrop implements
2023-12-08 05:10:22 +08:00
@IConfigurationService private configurationService: IConfigurationService,
@IInstantiationService private instantiationService: IInstantiationService,
@IWorkspaceEditingService private workspaceEditingService: IWorkspaceEditingService,
- @IUriIdentityService private readonly uriIdentityService: IUriIdentityService
+ @IUriIdentityService private readonly uriIdentityService: IUriIdentityService,
+ @IBrowserWorkbenchEnvironmentService protected readonly environmentService: IBrowserWorkbenchEnvironmentService
) {
const updateDropEnablement = (e: IConfigurationChangeEvent | undefined) => {
if (!e || e.affectsConfiguration('explorer.enableDragAndDrop')) {
2024-04-06 06:20:28 +08:00
@@ -1305,15 +1307,17 @@ export class FileDragAndDrop implements
2023-12-08 05:10:22 +08:00
// External file DND (Import/Upload file)
if (data instanceof NativeDragAndDropData) {
- // Use local file import when supported
2023-12-16 05:38:01 +08:00
- if (!isWeb || (isTemporaryWorkspace(this.contextService.getWorkspace()) && WebFileSystemAccess.supported(mainWindow))) {
2023-12-08 05:10:22 +08:00
- const fileImport = this.instantiationService.createInstance(ExternalFileImport);
2023-12-16 05:38:01 +08:00
- await fileImport.import(resolvedTarget, originalEvent, mainWindow);
2023-12-08 05:10:22 +08:00
- }
- // Otherwise fallback to browser based file upload
- else {
- const browserUpload = this.instantiationService.createInstance(BrowserFileUpload);
- await browserUpload.upload(target, originalEvent);
+ if (this.environmentService.isEnabledFileUploads) {
+ // Use local file import when supported
2023-12-16 05:38:01 +08:00
+ if (!isWeb || (isTemporaryWorkspace(this.contextService.getWorkspace()) && WebFileSystemAccess.supported(mainWindow))) {
2023-12-08 05:10:22 +08:00
+ const fileImport = this.instantiationService.createInstance(ExternalFileImport);
2023-12-16 05:38:01 +08:00
+ await fileImport.import(resolvedTarget, originalEvent, mainWindow);
2023-12-08 05:10:22 +08:00
+ }
+ // Otherwise fallback to browser based file upload
+ else {
+ const browserUpload = this.instantiationService.createInstance(BrowserFileUpload);
+ await browserUpload.upload(target, originalEvent);
+ }
}
}
Index: code-server/lib/vscode/src/vs/platform/files/node/diskFileSystemProviderServer.ts
===================================================================
--- code-server.orig/lib/vscode/src/vs/platform/files/node/diskFileSystemProviderServer.ts
+++ code-server/lib/vscode/src/vs/platform/files/node/diskFileSystemProviderServer.ts
@@ -92,6 +92,7 @@ export abstract class AbstractDiskFileSy
private async readFile(uriTransformer: IURITransformer, _resource: UriComponents, opts?: IFileAtomicReadOptions): Promise<VSBuffer> {
const resource = this.transformIncoming(uriTransformer, _resource, true);
+ this.logService.trace(`File action: readFile ${resource.path}`);
const buffer = await this.provider.readFile(resource, opts);
return VSBuffer.wrap(buffer);
@@ -110,6 +111,7 @@ export abstract class AbstractDiskFileSy
}
});
+ this.logService.trace(`File action: readFileStream ${resource.path}`);
const fileStream = this.provider.readFileStream(resource, opts, cts.token);
listenStream(fileStream, {
onData: chunk => emitter.fire(VSBuffer.wrap(chunk)),
@@ -130,7 +132,7 @@ export abstract class AbstractDiskFileSy
private writeFile(uriTransformer: IURITransformer, _resource: UriComponents, content: VSBuffer, opts: IFileWriteOptions): Promise<void> {
const resource = this.transformIncoming(uriTransformer, _resource);
-
+ this.logService.trace(`File action: writeFile ${resource.path}`);
return this.provider.writeFile(resource, content.buffer, opts);
}