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-11-01 03:49:03 +08:00
@@ -335,6 +335,8 @@ export class WebClientServer {
2024-04-06 06:20:28 +08:00
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
2024-10-18 12:31:28 +08:00
@@ -7,11 +7,11 @@ import { Event } from '../../base/common
import { Disposable } from '../../base/common/lifecycle.js';
import { IContextKeyService, IContextKey, setConstant as setConstantContextKey } from '../../platform/contextkey/common/contextkey.js';
import { InputFocusedContext, IsMacContext, IsLinuxContext, IsWindowsContext, IsWebContext, IsMacNativeContext, IsDevelopmentContext, IsIOSContext, ProductQualityContext, IsMobileContext } from '../../platform/contextkey/common/contextkeys.js';
-import { SplitEditorsVertically, InEditorZenModeContext, AuxiliaryBarVisibleContext, SideBarVisibleContext, PanelAlignmentContext, PanelMaximizedContext, PanelVisibleContext, EmbedderIdentifierContext, EditorTabsVisibleContext, IsMainEditorCenteredLayoutContext, MainEditorAreaVisibleContext, DirtyWorkingCopiesContext, EmptyWorkspaceSupportContext, EnterMultiRootWorkspaceSupportContext, HasWebFileSystemAccess, IsMainWindowFullscreenContext, OpenFolderWorkspaceSupportContext, RemoteNameContext, VirtualWorkspaceContext, WorkbenchStateContext, WorkspaceFolderCountContext, PanelPositionContext, TemporaryWorkspaceContext, TitleBarVisibleContext, TitleBarStyleContext, IsAuxiliaryWindowFocusedContext, ActiveEditorGroupEmptyContext, ActiveEditorGroupIndexContext, ActiveEditorGroupLastContext, ActiveEditorGroupLockedContext, MultipleEditorGroupsContext, EditorsVisibleContext } from '../common/contextkeys.js';
+import { SplitEditorsVertically, InEditorZenModeContext, AuxiliaryBarVisibleContext, SideBarVisibleContext, PanelAlignmentContext, PanelMaximizedContext, PanelVisibleContext, EmbedderIdentifierContext, EditorTabsVisibleContext, IsMainEditorCenteredLayoutContext, MainEditorAreaVisibleContext, DirtyWorkingCopiesContext, EmptyWorkspaceSupportContext, EnterMultiRootWorkspaceSupportContext, HasWebFileSystemAccess, IsMainWindowFullscreenContext, OpenFolderWorkspaceSupportContext, RemoteNameContext, VirtualWorkspaceContext, WorkbenchStateContext, WorkspaceFolderCountContext, PanelPositionContext, TemporaryWorkspaceContext, TitleBarVisibleContext, TitleBarStyleContext, IsAuxiliaryWindowFocusedContext, ActiveEditorGroupEmptyContext, ActiveEditorGroupIndexContext, ActiveEditorGroupLastContext, ActiveEditorGroupLockedContext, MultipleEditorGroupsContext, EditorsVisibleContext, IsEnabledFileDownloads, IsEnabledFileUploads } from '../common/contextkeys.js';
import { trackFocus, addDisposableListener, EventType, onDidRegisterWindow, getActiveWindow, isEditableElement } from '../../base/browser/dom.js';
import { preferredSideBySideGroupDirection, GroupDirection, IEditorGroupsService } from '../services/editor/common/editorGroupsService.js';
import { IConfigurationService } from '../../platform/configuration/common/configuration.js';
-import { IWorkbenchEnvironmentService } from '../services/environment/common/environmentService.js';
+import { IBrowserWorkbenchEnvironmentService } from '../services/environment/browser/environmentService.js';
import { WorkbenchState, IWorkspaceContextService, isTemporaryWorkspace } from '../../platform/workspace/common/workspace.js';
import { IWorkbenchLayoutService, Parts, positionToString } from '../services/layout/browser/layoutService.js';
import { getRemoteName } from '../../platform/remote/common/remoteHosts.js';
2024-06-07 07:02:13 +08:00
@@ -70,7 +70,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,
2024-06-07 07:02:13 +08:00
@IEditorGroupsService private readonly editorGroupService: IEditorGroupsService,
2022-04-14 00:39:05 +08:00
@IEditorService private readonly editorService: IEditorService,
2024-06-07 07:02:13 +08:00
@@ -197,6 +197,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,
2024-10-18 12:31:28 +08:00
import { AutoSaveAfterShortDelayContext } from '../../../services/filesConfiguration/common/filesConfigurationService.js';
import { WorkbenchListDoubleSelection, WorkbenchTreeFindOpen } from '../../../../platform/list/browser/listService.js';
import { Schemas } from '../../../../base/common/network.js';
-import { DirtyWorkingCopiesContext, EnterMultiRootWorkspaceSupportContext, HasWebFileSystemAccess, WorkbenchStateContext, WorkspaceFolderCountContext, SidebarFocusContext, ActiveEditorCanRevertContext, ActiveEditorContext, ResourceContextKey, ActiveEditorAvailableEditorIdsContext, MultipleEditorsSelectedInGroupContext, TwoEditorsSelectedInGroupContext, SelectedEditorsInGroupFileOrUntitledResourceContextKey } from '../../../common/contextkeys.js';
+import { IsEnabledFileDownloads, IsEnabledFileUploads, DirtyWorkingCopiesContext, EnterMultiRootWorkspaceSupportContext, HasWebFileSystemAccess, WorkbenchStateContext, WorkspaceFolderCountContext, SidebarFocusContext, ActiveEditorCanRevertContext, ActiveEditorContext, ResourceContextKey, ActiveEditorAvailableEditorIdsContext, MultipleEditorsSelectedInGroupContext, TwoEditorsSelectedInGroupContext, SelectedEditorsInGroupFileOrUntitledResourceContextKey } from '../../../common/contextkeys.js';
import { IsWebContext } from '../../../../platform/contextkey/common/contextkeys.js';
import { ServicesAccessor } from '../../../../platform/instantiation/common/instantiation.js';
import { ThemeIcon } from '../../../../base/common/themables.js';
@@ -572,13 +572,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-10-18 12:31:28 +08:00
@@ -590,6 +593,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
2024-10-18 12:31:28 +08:00
@@ -18,7 +18,7 @@ import { IModelService } from '../../../
import { ILanguageService } from '../../../../editor/common/languages/language.js';
import { getIconClasses } from '../../../../editor/common/services/getIconClasses.js';
import { Schemas } from '../../../../base/common/network.js';
-import { IWorkbenchEnvironmentService } from '../../environment/common/environmentService.js';
+import { IBrowserWorkbenchEnvironmentService } from '../../environment/browser/environmentService.js';
import { IRemoteAgentService } from '../../remote/common/remoteAgentService.js';
import { IContextKeyService, IContextKey, RawContextKey } from '../../../../platform/contextkey/common/contextkey.js';
import { equalsIgnoreCase, format, startsWithIgnoreCase } from '../../../../base/common/strings.js';
@@ -139,7 +139,7 @@ export class SimpleFileDialog extends Di
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-10-18 12:31:28 +08:00
@@ -283,20 +283,22 @@ export class SimpleFileDialog extends Di
2024-02-02 09:36:47 +08:00
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
2024-10-18 12:31:28 +08:00
@@ -65,6 +65,7 @@ import { timeout } from '../../../../../
import { IFilesConfigurationService } from '../../../../services/filesConfiguration/common/filesConfigurationService.js';
import { mainWindow } from '../../../../../base/browser/window.js';
import { IExplorerFileContribution, explorerFileContribRegistry } from '../explorerFileContrib.js';
+import { IBrowserWorkbenchEnvironmentService } from '../../../../services/environment/browser/environmentService.js';
2023-12-08 05:10:22 +08:00
export class ExplorerDelegate implements IListVirtualDelegate<ExplorerItem> {
2024-06-07 07:02:13 +08:00
2024-10-18 12:31:28 +08:00
@@ -1030,7 +1031,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-10-18 12:31:28 +08:00
@@ -1255,15 +1257,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);
}