Skip to content

Commit d346b81

Browse files
Akos KittaChristian Weichel
authored andcommitted
Changed the way we init default locations.
For the `data` and `downloads`. Signed-off-by: Akos Kitta <kittaakos@typefox.io>
1 parent bfb0edf commit d346b81

File tree

3 files changed

+4
-41
lines changed

3 files changed

+4
-41
lines changed
Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { inject, injectable } from 'inversify';
2-
import URI from '@theia/core/lib/common/uri';
32
import { FileSystem } from '@theia/filesystem/lib/common';
43
import { WorkspaceService } from '@theia/workspace/lib/browser/workspace-service';
54
import { WorkspaceServiceExt } from './workspace-service-ext';
@@ -21,27 +20,4 @@ export class WorkspaceServiceExtImpl implements WorkspaceServiceExt {
2120
return stats.map(stat => stat.uri);
2221
}
2322

24-
async defaultWorkspaceUri(): Promise<string> {
25-
const home = await this.fileSystem.getCurrentUserHome();
26-
if (home) {
27-
return new URI(home.uri).resolve('Arduino-PoC').resolve('workspace').toString();
28-
}
29-
throw new Error(`Could not locate current user's home folder.`);
30-
}
31-
32-
async defaultDownloadsDirUri(): Promise<string> {
33-
const home = await this.fileSystem.getCurrentUserHome();
34-
if (home) {
35-
return new URI(home.uri).resolve('Arduino-PoC').resolve('downloads').toString();
36-
}
37-
throw new Error(`Could not locate current user's home folder.`);
38-
}
39-
40-
async defaultDataDirUri(): Promise<string> {
41-
const home = await this.fileSystem.getCurrentUserHome();
42-
if (home) {
43-
return new URI(home.uri).resolve('Arduino-PoC').resolve('data').toString();
44-
}
45-
throw new Error(`Could not locate current user's home folder.`);
46-
}
4723
}

arduino-ide-extension/src/browser/workspace-service-ext.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,4 @@ export const WorkspaceServiceExtPath = '/services/workspace-service-ext';
22
export const WorkspaceServiceExt = Symbol('WorkspaceServiceExt');
33
export interface WorkspaceServiceExt {
44
roots(): Promise<string[]>;
5-
/**
6-
* By default it is under `~/Arduino-PoC/workspace`.
7-
* It might not exist yet.
8-
*/
9-
defaultWorkspaceUri(): Promise<string>;
10-
defaultDownloadsDirUri(): Promise<string>;
11-
defaultDataDirUri(): Promise<string>;
125
}

arduino-ide-extension/src/node/core-client-provider-impl.ts

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ import * as PQueue from 'p-queue';
1010
import { ToolOutputServiceServer } from '../common/protocol/tool-output-service';
1111
import { Instance } from './cli-protocol/common_pb';
1212
import * as fs from 'fs-extra';
13+
import * as path from 'path';
14+
import * as os from 'os';
1315

1416
@injectable()
1517
export class CoreClientProviderImpl implements CoreClientProvider {
@@ -66,20 +68,12 @@ export class CoreClientProviderImpl implements CoreClientProvider {
6668
throw new Error(`Could not resolve filesystem path of URI: ${rootUri}.`);
6769
}
6870

69-
const defaultDownloadsDirUri = await this.workspaceServiceExt.defaultDownloadsDirUri();
70-
const defaultDownloadsDirPath = await this.fileSystem.getFsPath(defaultDownloadsDirUri);
71-
if (!defaultDownloadsDirPath) {
72-
throw new Error(`Could not resolve filesystem path of URI: ${defaultDownloadsDirUri}.`);
73-
}
71+
const defaultDownloadsDirPath = path.resolve(os.homedir(), 'Arduino-PoC', 'downloads');
7472
if (!fs.existsSync(defaultDownloadsDirPath)) {
7573
fs.mkdirpSync(defaultDownloadsDirPath);
7674
}
7775

78-
const defaultDataDirUri = await this.workspaceServiceExt.defaultDataDirUri();
79-
const defaultDataDirPath = await this.fileSystem.getFsPath(defaultDataDirUri);
80-
if (!defaultDataDirPath) {
81-
throw new Error(`Could not resolve filesystem path of URI: ${defaultDataDirUri}.`);
82-
}
76+
const defaultDataDirPath = path.resolve(os.homedir(), 'Arduino-PoC', 'data')
8377
if (!fs.existsSync(defaultDataDirPath)) {
8478
fs.mkdirpSync(defaultDataDirPath);
8579
}

0 commit comments

Comments
 (0)