[core] Always save config, not null
This commit is contained in:
1 parent
ad10ea4e96
commit
0b5af3145e
3 files changed
+5
-5
No files matched your search
@@ -3,7 +3,7 @@ import { SessionConfig } from '../../structures/sessions.dto';
|
||||
export abstract class ISessionConfigRepository {
|
||||
abstract saveConfig(
|
||||
sessionName: string,
|
||||
config: SessionConfig | null,
|
||||
config: SessionConfig,
|
||||
): Promise<void>;
|
||||
|
||||
abstract getConfig(sessionName: string): Promise<SessionConfig | null>;
|
||||
|
||||
@@ -48,13 +48,13 @@ export class LocalSessionConfigRepository extends ISessionConfigRepository {
|
||||
return JSON.parse(content);
|
||||
}
|
||||
|
||||
async saveConfig(sessionName: string, config: SessionConfig | null) {
|
||||
// Create folder if not exist
|
||||
async saveConfig(sessionName: string, config: SessionConfig) {
|
||||
// Create a folder if not exist
|
||||
const folder = this.store.getSessionDirectory(sessionName);
|
||||
await fs.mkdir(folder, { recursive: true });
|
||||
// Save config
|
||||
const filepath = this.getFilePath(sessionName);
|
||||
const content = JSON.stringify(config || null);
|
||||
const content = JSON.stringify(config || {});
|
||||
await writeFileAtomic(filepath, content);
|
||||
}
|
||||
|
||||
|
||||
@@ -122,7 +122,7 @@ export class SessionConfig {
|
||||
})
|
||||
@IsBoolean()
|
||||
@IsOptional()
|
||||
debug: boolean;
|
||||
debug?: boolean;
|
||||
|
||||
@ApiProperty({
|
||||
example: {
|
||||
|
||||
Reference in new issue
Block a user