fix recent searches path

This commit is contained in:
Jurgis Sakalauskas
2022-12-09 18:13:11 +02:00
parent cd4ba620de
commit 58d85371ef
2 changed files with 7 additions and 3 deletions
@@ -35,15 +35,19 @@ export class RecentSearchesService {
} }
data.push(term); data.push(term);
const rawData = JSON.stringify(data); const rawData = JSON.stringify(data);
const filePath = join(this.configService.getRecentSearchesFolder(), module); const filePath = this.getFilePath(module);
await writeFile(filePath, rawData); await writeFile(filePath, rawData);
} }
private async getRecentSearchesData(module: string): Promise<Array<string>> { private async getRecentSearchesData(module: string): Promise<Array<string>> {
const filePath = join(this.configService.getRecentSearchesFolder(), module); const filePath = this.getFilePath(module);
const rawData = '' + (await readFile(filePath).catch(() => '[]')); const rawData = '' + (await readFile(filePath).catch(() => '[]'));
return JSON.parse(rawData); return JSON.parse(rawData);
} }
private getFilePath(module: string): string {
return join(this.configService.getRecentSearchesFolder(), module + '.json');
}
} }
+1 -1
View File
@@ -33,7 +33,7 @@ export class ConfigService {
} }
public getRecentSearchesFolder(): string { public getRecentSearchesFolder(): string {
return join(this.getRootPath(), this.getEnv('STATIC_SERVE_FOLDER')); return join(this.getRootPath(), this.getEnv('RECENT_SEARCHES_FOLDER'));
} }
private getRootPath(): string { private getRootPath(): string {