Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fef2bcb6e2 |
@@ -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