Skip to content

Commit

Permalink
fix: code service support configure fs (#128)
Browse files Browse the repository at this point in the history
  • Loading branch information
bytemain authored Aug 16, 2024
1 parent 1f46c48 commit b5616d9
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 6 deletions.
5 changes: 5 additions & 0 deletions packages/code-service/src/code-service.contribution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
CODE_ROOT,
IDB_ROOT,
IServerApp,
isPathMounted,
LaunchContribution,
RootFS,
RuntimeConfig,
Expand Down Expand Up @@ -221,6 +222,10 @@ export class CodeContribution

this._unmount?.();

if (isPathMounted(rootFS, workspaceDir)) {
rootFS.umount(workspaceDir);
}

rootFS.mount(workspaceDir, overlayFileSystem);
// 将只读文件系统挂载到 /code 上
rootFS.mount(CODE_ROOT, codeFileSystem);
Expand Down
7 changes: 6 additions & 1 deletion packages/startup/src/startup/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,12 @@ const App = () => (
}}
runtimeConfig={{
scmFileTree: true,
scenario: 'ALEX_TEST',
scenario: 'startup',
workspace: {
filesystem: {
fs: 'InMemory'
}
},
aiNative: {
enable: true,
providerEditorInlineChat(): IEditorInlineChat[] {
Expand Down
2 changes: 1 addition & 1 deletion packages/sumi-core/src/server/core/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import { RawMessageIO } from '@opensumi/ide-connection/lib/common/rpc/message-io
import { rawSerializer } from '@opensumi/ide-connection/lib/common/serializer/raw';
import {
BaseCommonChannelHandler,
RPCServiceChannelPath,
CommonChannelPathHandler,
RPCServiceChannelPath,
} from '@opensumi/ide-connection/lib/common/server-handler';
import { AppConfig, BrowserModule } from '@opensumi/ide-core-browser';
import {
Expand Down
5 changes: 2 additions & 3 deletions packages/sumi-core/src/server/core/fs-launch.contribution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Autowired } from '@opensumi/di';
import { ContributionProvider, Disposable, Domain, localize } from '@opensumi/ide-core-common';
import { IMessageService } from '@opensumi/ide-overlay';
import { AppConfig, IServerApp, RootFS, RuntimeConfig } from '../../common/types';
import { BrowserFS } from '../node';
import { BrowserFS, isPathMounted } from '../node';
import { LaunchContribution } from './app';
import { FileSystemContribution } from './base';

Expand Down Expand Up @@ -39,8 +39,7 @@ export class FileSystemConfigContribution extends Disposable implements FileSyst
const fsConfig = this.runtimeConfig.workspace?.filesystem;
if (!fsConfig) return;
const { workspaceDir } = this.appConfig;
// @ts-ignore
if (rootFS && rootFS.mountList.includes(workspaceDir)) {
if (isPathMounted(rootFS, workspaceDir)) {
return;
}
try {
Expand Down
11 changes: 10 additions & 1 deletion packages/sumi-core/src/server/node/bfs/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import MountableFileSystem, {
} from '@codeblitzjs/ide-browserfs/lib/backend/MountableFileSystem';
import OverlayFS, { deletionLogPath, OverlayFSOptions } from '@codeblitzjs/ide-browserfs/lib/backend/OverlayFS';
import ZipFS, { ZipFSOptions } from '@codeblitzjs/ide-browserfs/lib/backend/ZipFS';
import { WORKSPACE_IDB_NAME } from '../../../common';
import { RootFS, WORKSPACE_IDB_NAME } from '../../../common';
import { Editor, EditorOptions } from './Editor';
import { FileIndexSystem, FileIndexSystemOptions } from './FileIndex';

Expand Down Expand Up @@ -179,3 +179,12 @@ type InstanceType<T> = T extends { Create(options: object, cb: BFSCallback<infer
: any;

export type FileSystemInstance<T extends SupportFileSystem> = InstanceType<(typeof Backends)[T]>;

export function isPathMounted(fs: RootFS, path: string): boolean {
// @ts-ignore
if (fs && fs.mountList.includes(path)) {
return true;
}

return false;
}

1 comment on commit b5616d9

@opensumi
Copy link
Contributor

@opensumi opensumi bot commented on b5616d9 Aug 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎉 Next publish successful!

0.0.20240816073721-main.0

Please sign in to comment.