mirror of
https://github.com/Zagrios/bs-manager.git
synced 2026-07-03 14:08:25 +02:00
[feat-560] ask user for installation folder/path
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import ElectronStore from "electron-store";
|
||||
import fs from "fs-extra";
|
||||
import { InstallationLocationService } from "./installation-location.service";
|
||||
|
||||
export class ConfigurationService {
|
||||
@@ -17,13 +18,17 @@ export class ConfigurationService {
|
||||
|
||||
private constructor() {
|
||||
this.locations = InstallationLocationService.getInstance();
|
||||
this.initStore();
|
||||
this.initStore(false);
|
||||
|
||||
this.locations.onInstallLocationUpdate(() => { this.initStore() });
|
||||
this.locations.onInstallLocationUpdate(() => this.initStore(true));
|
||||
}
|
||||
|
||||
private async initStore() {
|
||||
private async initStore(createFolder: boolean) {
|
||||
const contentPath = this.locations.installationDirectory();
|
||||
if (!createFolder && !fs.pathExistsSync(contentPath)) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.store = new ElectronStore({
|
||||
cwd: contentPath,
|
||||
name: "config",
|
||||
|
||||
@@ -59,6 +59,12 @@ export class InstallationLocationService {
|
||||
this.updateListeners.add(fn);
|
||||
}
|
||||
|
||||
public defaultInstallationDirectory(): string {
|
||||
const { result: oldPath } = tryit(() => path.join(app.getPath("documents"), this.INSTALLATION_FOLDER));
|
||||
const installationDirectory = (oldPath && pathExistsSync(oldPath)) ? app.getPath("documents") : app.getPath("home");
|
||||
return path.join(installationDirectory, this.INSTALLATION_FOLDER);
|
||||
}
|
||||
|
||||
public installationDirectory(): string {
|
||||
|
||||
const installParentPath = () => {
|
||||
|
||||
Reference in New Issue
Block a user