mirror of
https://github.com/arduino/arduino-ide.git
synced 2025-11-13 20:29:27 +00:00
Guard against no workspaces root.
Signed-off-by: Akos Kitta <kittaakos@typefox.io>
This commit is contained in:
committed by
Christian Weichel
parent
d8625ad9c3
commit
bfb0edf50c
@@ -1,4 +1,6 @@
|
||||
import { inject, injectable } from 'inversify';
|
||||
import URI from '@theia/core/lib/common/uri';
|
||||
import { FileSystem } from '@theia/filesystem/lib/common';
|
||||
import { WorkspaceService } from '@theia/workspace/lib/browser/workspace-service';
|
||||
import { WorkspaceServiceExt } from './workspace-service-ext';
|
||||
|
||||
@@ -8,6 +10,9 @@ import { WorkspaceServiceExt } from './workspace-service-ext';
|
||||
@injectable()
|
||||
export class WorkspaceServiceExtImpl implements WorkspaceServiceExt {
|
||||
|
||||
@inject(FileSystem)
|
||||
protected readonly fileSystem: FileSystem;
|
||||
|
||||
@inject(WorkspaceService)
|
||||
protected readonly delegate: WorkspaceService;
|
||||
|
||||
@@ -16,4 +21,27 @@ export class WorkspaceServiceExtImpl implements WorkspaceServiceExt {
|
||||
return stats.map(stat => stat.uri);
|
||||
}
|
||||
|
||||
}
|
||||
async defaultWorkspaceUri(): Promise<string> {
|
||||
const home = await this.fileSystem.getCurrentUserHome();
|
||||
if (home) {
|
||||
return new URI(home.uri).resolve('Arduino-PoC').resolve('workspace').toString();
|
||||
}
|
||||
throw new Error(`Could not locate current user's home folder.`);
|
||||
}
|
||||
|
||||
async defaultDownloadsDirUri(): Promise<string> {
|
||||
const home = await this.fileSystem.getCurrentUserHome();
|
||||
if (home) {
|
||||
return new URI(home.uri).resolve('Arduino-PoC').resolve('downloads').toString();
|
||||
}
|
||||
throw new Error(`Could not locate current user's home folder.`);
|
||||
}
|
||||
|
||||
async defaultDataDirUri(): Promise<string> {
|
||||
const home = await this.fileSystem.getCurrentUserHome();
|
||||
if (home) {
|
||||
return new URI(home.uri).resolve('Arduino-PoC').resolve('data').toString();
|
||||
}
|
||||
throw new Error(`Could not locate current user's home folder.`);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,4 +2,11 @@ export const WorkspaceServiceExtPath = '/services/workspace-service-ext';
|
||||
export const WorkspaceServiceExt = Symbol('WorkspaceServiceExt');
|
||||
export interface WorkspaceServiceExt {
|
||||
roots(): Promise<string[]>;
|
||||
/**
|
||||
* By default it is under `~/Arduino-PoC/workspace`.
|
||||
* It might not exist yet.
|
||||
*/
|
||||
defaultWorkspaceUri(): Promise<string>;
|
||||
defaultDownloadsDirUri(): Promise<string>;
|
||||
defaultDataDirUri(): Promise<string>;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user