mirror of
https://github.com/bitwarden/browser
synced 2025-12-19 17:53:39 +00:00
Set paths for portable builds
This commit is contained in:
@@ -5,33 +5,31 @@ import { ConstantsService } from 'jslib/services/constants.service';
|
||||
// tslint:disable-next-line
|
||||
const Store = require('electron-store');
|
||||
|
||||
const storeConfig: any = {
|
||||
defaults: {} as any,
|
||||
name: 'bitwarden-data',
|
||||
};
|
||||
|
||||
// Default lock options to "on restart".
|
||||
storeConfig.defaults[ConstantsService.lockOptionKey] = -1;
|
||||
// Portable builds should not use app data
|
||||
if (process.env.PORTABLE_EXECUTABLE_DIR != null) {
|
||||
storeConfig.cwd = process.env.PORTABLE_EXECUTABLE_DIR;
|
||||
}
|
||||
|
||||
const store = new Store(storeConfig);
|
||||
|
||||
export class DesktopStorageService implements StorageService {
|
||||
private store: any;
|
||||
|
||||
constructor() {
|
||||
const storeConfig: any = {
|
||||
defaults: {} as any,
|
||||
name: 'data',
|
||||
};
|
||||
// Default lock options to "on restart".
|
||||
storeConfig.defaults[ConstantsService.lockOptionKey] = -1;
|
||||
this.store = new Store(storeConfig);
|
||||
}
|
||||
|
||||
get<T>(key: string): Promise<T> {
|
||||
const val = store.get(key) as T;
|
||||
const val = this.store.get(key) as T;
|
||||
return Promise.resolve(val != null ? val : null);
|
||||
}
|
||||
|
||||
save(key: string, obj: any): Promise<any> {
|
||||
store.set(key, obj);
|
||||
this.store.set(key, obj);
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
remove(key: string): Promise<any> {
|
||||
store.delete(key);
|
||||
this.store.delete(key);
|
||||
return Promise.resolve();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user