This commit is contained in:
1 parent
2f6ed2fb58
commit
fef2bcb6e2
1 file changed
+12
-1
@@ -39,11 +39,22 @@ class LocalSessionConfigRepository extends SessionConfigRepository {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const content = await fs.readFile(filepath, 'utf-8');
|
||||
// Try to load config
|
||||
let content;
|
||||
try {
|
||||
content = await fs.readFile(filepath, 'utf-8');
|
||||
} catch (error) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
return JSON.parse(content);
|
||||
}
|
||||
|
||||
async save(sessionName: string, config: SessionConfig) {
|
||||
// Create folder if not exist
|
||||
const folder = this.storage.getFolderPath(sessionName);
|
||||
await fs.mkdir(folder, { recursive: true });
|
||||
// Save config
|
||||
const filepath = this.getFilePath(sessionName);
|
||||
const content = JSON.stringify(config || null);
|
||||
await fs.writeFile(filepath, content);
|
||||
|
||||
Reference in new issue
Block a user