mirror of
https://github.com/coder/code-server.git
synced 2026-11-28 23:07:21 +08:00
* Stop generating shrinkwraps npm 12 removes support for shrinkwraps. Additionally, VS Code has switched to pnpm and this will make generating the shrinkwraps less straightforward. Exact pins in the package.json would not be a sufficient replacement since that does not cover transitive dependencies. The recommendation for end user packages installed globally with npm seems to be to be to bundle dependencies. One idea would be to build for every platform and bundle them all, but the whole reason we have the npm package is to support platforms for which we are not building. If we build them, we could just add a regular release for that platform on GitHub. So instead for each native module we would need to add rebuild commands in the postinstall. And ideally remove the current platform builds to at least try keeping the tarball size down. I am not sure it is worth the effort for what it feels like fighting with npm, so this change does not attempt that. * Remove devDependencies from extensions package.json Not strictly necessary since we only install production dependencies in the postinstall, but might as well save some bytes. * Update Code to 1.146.0 * Support pnpm for post-install * Get Node version from package.json lib/vscode/remote/.npmrc no longer exists * Switch to pnpm VS Code recently switched to pnpm so various scripts needed to be updated, and we might as well follow suite with code-server's own dependencies. In general this change just swaps out "npm" invocations for "pnpm" plus any necessary flag changes to match but to call out some less obvious changes: 1. The extensions directory no longer has a post-install script, so there is no need to copy one anymore. 2. When merging the remote package.json, only copy the dependencies since that is all we need, to avoid copying in new properties like packageManager. 3. Remove unused publish:npm. It points to a nonexistent file anyway. 4. Remove publish:docker and just call the script directly, to avoid an npm/pnpm dependency in a job that really has no need for it. * Update nfpm maintainer
359 lines
23 KiB
Diff
359 lines
23 KiB
Diff
Add option to disable file downloads and uploads via cli
|
|
|
|
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
|
|
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`.
|
|
|
|
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,
|
|
right-click on a file (not a folder) and you should **not** see the
|
|
"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.
|
|
|
|
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
|
|
@@ -319,6 +319,16 @@ export interface IWorkbenchConstructionO
|
|
*/
|
|
readonly userDataPath?: string
|
|
|
|
+ /**
|
|
+ * Whether the "Download..." option is enabled for files.
|
|
+ */
|
|
+ readonly isEnabledFileDownloads?: boolean
|
|
+
|
|
+ /**
|
|
+ * Whether the "Upload..." button is enabled.
|
|
+ */
|
|
+ readonly isEnabledFileUploads?: boolean
|
|
+
|
|
//#endregion
|
|
|
|
//#region Profile options
|
|
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
|
|
@@ -39,6 +39,16 @@ export interface IBrowserWorkbenchEnviro
|
|
readonly sessionTitle?: string;
|
|
|
|
/**
|
|
+ * Enable downloading files via menu actions.
|
|
+ */
|
|
+ readonly isEnabledFileDownloads?: boolean;
|
|
+
|
|
+ /**
|
|
+ * Enable uploading files via menu actions.
|
|
+ */
|
|
+ readonly isEnabledFileUploads?: boolean;
|
|
+
|
|
+ /**
|
|
* Gets whether a resolver extension is expected for the environment.
|
|
*/
|
|
readonly expectsResolverExtension: boolean;
|
|
@@ -116,6 +126,20 @@ export class BrowserWorkbenchEnvironment
|
|
return this.options.userDataPath;
|
|
}
|
|
|
|
+ get isEnabledFileDownloads(): boolean {
|
|
+ if (typeof this.options.isEnabledFileDownloads === "undefined") {
|
|
+ throw new Error('isEnabledFileDownloads was not provided to the browser');
|
|
+ }
|
|
+ return this.options.isEnabledFileDownloads;
|
|
+ }
|
|
+
|
|
+ get isEnabledFileUploads(): boolean {
|
|
+ if (typeof this.options.isEnabledFileUploads === "undefined") {
|
|
+ throw new Error('isEnabledFileUploads was not provided to the browser');
|
|
+ }
|
|
+ return this.options.isEnabledFileUploads;
|
|
+ }
|
|
+
|
|
@memoize
|
|
get argvResource(): URI { return joinPath(this.userRoamingDataHome, 'argv.json'); }
|
|
|
|
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
|
|
@@ -35,6 +35,8 @@ export const serverOptions: OptionDescri
|
|
/* ----- code-server ----- */
|
|
'disable-update-check': { type: 'boolean' },
|
|
'auth': { type: 'string' },
|
|
+ 'disable-file-downloads': { type: 'boolean' },
|
|
+ 'disable-file-uploads': { type: 'boolean' },
|
|
|
|
/* ----- server setup ----- */
|
|
|
|
@@ -130,6 +132,8 @@ export interface ServerParsedArgs {
|
|
/* ----- code-server ----- */
|
|
'disable-update-check'?: boolean;
|
|
'auth'?: string;
|
|
+ 'disable-file-downloads'?: boolean;
|
|
+ 'disable-file-uploads'?: boolean;
|
|
|
|
/* ----- 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
|
|
@@ -425,6 +425,8 @@ export class WebClientServer {
|
|
serverBasePath: basePath,
|
|
webviewEndpoint: staticRoute + '/out/vs/workbench/contrib/webview/browser/pre',
|
|
userDataPath: this._environmentService.userDataPath,
|
|
+ isEnabledFileDownloads: !this._environmentService.args['disable-file-downloads'],
|
|
+ isEnabledFileUploads: !this._environmentService.args['disable-file-uploads'],
|
|
_wrapWebWorkerExtHostInIframe,
|
|
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,
|
|
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
|
|
@@ -6,10 +6,10 @@
|
|
import { Disposable } from '../../base/common/lifecycle.js';
|
|
import { IContextKeyService, IContextKey, setConstant as setConstantContextKey } from '../../platform/contextkey/common/contextkey.js';
|
|
import { IsMacContext, IsLinuxContext, IsWindowsContext, IsWebContext, IsMacNativeContext, IsDevelopmentContext, IsIOSContext, ProductQualityContext, IsMobileContext, IsChromeOSContext } from '../../platform/contextkey/common/contextkeys.js';
|
|
-import { SplitEditorsVertically, InEditorZenModeContext, AuxiliaryBarVisibleContext, SecondarySideBarVisibleContext, 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, AuxiliaryBarMaximizedContext, InAutomationContext, IsSessionsWindowContext } from '../common/contextkeys.js';
|
|
+import { IsEnabledFileDownloads, IsEnabledFileUploads, SplitEditorsVertically, InEditorZenModeContext, AuxiliaryBarVisibleContext, SecondarySideBarVisibleContext, 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, AuxiliaryBarMaximizedContext, InAutomationContext, IsSessionsWindowContext } from '../common/contextkeys.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';
|
|
@@ -70,7 +70,7 @@ export class WorkbenchContextKeysHandler
|
|
@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,
|
|
@IProductService private readonly productService: IProductService,
|
|
@IEditorGroupsService private readonly editorGroupService: IEditorGroupsService,
|
|
@IEditorService private readonly editorService: IEditorService,
|
|
@@ -206,6 +206,10 @@ export class WorkbenchContextKeysHandler
|
|
this.auxiliaryBarMaximizedContext = AuxiliaryBarMaximizedContext.bindTo(this.contextKeyService);
|
|
this.auxiliaryBarMaximizedContext.set(this.layoutService.isAuxiliaryBarMaximized());
|
|
|
|
+ // code-server
|
|
+ IsEnabledFileDownloads.bindTo(this.contextKeyService).set(this.environmentService.isEnabledFileDownloads ?? true)
|
|
+ IsEnabledFileUploads.bindTo(this.contextKeyService).set(this.environmentService.isEnabledFileUploads ?? true)
|
|
+
|
|
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
|
|
@@ -20,7 +20,7 @@ import { CLOSE_SAVED_EDITORS_COMMAND_ID,
|
|
import { AutoSaveAfterShortDelayContext } from '../../../services/filesConfiguration/common/filesConfigurationService.js';
|
|
import { WorkbenchListDoubleSelection } from '../../../../platform/list/browser/listService.js';
|
|
import { Schemas } from '../../../../base/common/network.js';
|
|
-import { DirtyWorkingCopiesContext, EnterMultiRootWorkspaceSupportContext, HasWebFileSystemAccess, IsSessionsWindowContext, WorkbenchStateContext, WorkspaceFolderCountContext, SidebarFocusContext, ActiveEditorCanRevertContext, ActiveEditorContext, ActiveEditorDirtyContext, ResourceContextKey, ActiveEditorAvailableEditorIdsContext, MultipleEditorsSelectedInGroupContext, TwoEditorsSelectedInGroupContext, SelectedEditorsInGroupFileOrUntitledResourceContextKey } from '../../../common/contextkeys.js';
|
|
+import { IsEnabledFileDownloads, IsEnabledFileUploads, DirtyWorkingCopiesContext, EnterMultiRootWorkspaceSupportContext, HasWebFileSystemAccess, IsSessionsWindowContext, WorkbenchStateContext, WorkspaceFolderCountContext, SidebarFocusContext, ActiveEditorCanRevertContext, ActiveEditorContext, ActiveEditorDirtyContext, 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';
|
|
@@ -590,13 +590,16 @@ MenuRegistry.appendMenuItem(MenuId.Explo
|
|
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)
|
|
+ )
|
|
)
|
|
}));
|
|
|
|
@@ -608,6 +611,7 @@ MenuRegistry.appendMenuItem(MenuId.Explo
|
|
title: UPLOAD_LABEL,
|
|
},
|
|
when: ContextKeyExpr.and(
|
|
+ IsEnabledFileUploads,
|
|
// only in web
|
|
IsWebContext,
|
|
// only on folders
|
|
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
|
|
@@ -42,6 +42,9 @@ export const EmbedderIdentifierContext =
|
|
|
|
export const InAutomationContext = new RawContextKey<boolean>('inAutomation', false, localize('inAutomation', "Whether VS Code is running under automation/smoke test"));
|
|
|
|
+export const IsEnabledFileDownloads = new RawContextKey<boolean>('isEnabledFileDownloads', true, true);
|
|
+export const IsEnabledFileUploads = new RawContextKey<boolean>('isEnabledFileUploads', true, true);
|
|
+
|
|
//#endregion
|
|
|
|
//#region < --- Window --- >
|
|
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 '../../../
|
|
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';
|
|
@@ -153,7 +153,7 @@ export class SimpleFileDialog extends Di
|
|
@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,
|
|
@@ -372,21 +372,23 @@ export class SimpleFileDialog extends Di
|
|
: nls.localize('remoteFileDialog.placeholder', "Folder path");
|
|
this.filePickBox.ok = true;
|
|
this.filePickBox.okLabel = typeof this.options.openLabel === 'string' ? this.options.openLabel : this.options.openLabel?.withoutMnemonic;
|
|
- 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');
|
|
- this.filePickBox.customButtonSecondary = true;
|
|
- 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');
|
|
+ this.filePickBox.customButtonSecondary = true;
|
|
+ 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
|
|
@@ -62,6 +62,7 @@ import { defaultCountBadgeStyles } 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';
|
|
import { WorkbenchCompressibleAsyncDataTree } from '../../../../../platform/list/browser/listService.js';
|
|
import { ISearchService, QueryType, getExcludes, ISearchConfiguration, ISearchComplete, IFileQuery } from '../../../../services/search/common/search.js';
|
|
import { CancellationToken } from '../../../../../base/common/cancellation.js';
|
|
@@ -1562,7 +1563,8 @@ export class FileDragAndDrop implements
|
|
@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')) {
|
|
@@ -1787,15 +1789,17 @@ export class FileDragAndDrop implements
|
|
|
|
// External file DND (Import/Upload file)
|
|
if (data instanceof NativeDragAndDropData) {
|
|
- // Use local file import when supported
|
|
- if (!isWeb || (isTemporaryWorkspace(this.contextService.getWorkspace()) && WebFileSystemAccess.supported(mainWindow))) {
|
|
- const fileImport = this.instantiationService.createInstance(ExternalFileImport);
|
|
- await fileImport.import(resolvedTarget, originalEvent, mainWindow);
|
|
- }
|
|
- // 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
|
|
+ if (!isWeb || (isTemporaryWorkspace(this.contextService.getWorkspace()) && WebFileSystemAccess.supported(mainWindow))) {
|
|
+ const fileImport = this.instantiationService.createInstance(ExternalFileImport);
|
|
+ await fileImport.import(resolvedTarget, originalEvent, mainWindow);
|
|
+ }
|
|
+ // 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
|
|
@@ -100,6 +100,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);
|
|
@@ -118,6 +119,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)),
|
|
@@ -138,7 +140,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);
|
|
}
|
|
|