1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-12-24 10:27:10 +02:00

Fixes from review.

This commit is contained in:
Hubert 2023-08-06 12:06:38 -03:00
parent b35782fddb
commit 446845afde
2 changed files with 4 additions and 4 deletions

View File

@ -12,7 +12,7 @@ describe('RotatingLogs', () => {
try {
dir = await createTempDir();
await createTestLogFile(dir);
let files: string[] = await readdir(dir);
let files = await readdir(dir);
expect(files.find(file => file.match(/^log.txt$/gi))).toBeTruthy();
expect(files.length).toBe(1);
const rotatingLogs: RotatingLogs = new RotatingLogs(dir, 1, 1);
@ -35,7 +35,7 @@ describe('RotatingLogs', () => {
await rotatingLogs.cleanActiveLogFile();
await msleep(1);
await rotatingLogs.deleteNonActiveLogFiles();
const files: string[] = await readdir(dir);
const files = await readdir(dir);
expect(files.find(file => file.match(/^log-[0-9]+.txt$/gi))).toBeFalsy();
expect(files.length).toBe(0);
} finally {
@ -52,7 +52,7 @@ describe('RotatingLogs', () => {
const rotatingLogs: RotatingLogs = new RotatingLogs(dir, 1, 100);
await rotatingLogs.cleanActiveLogFile();
await rotatingLogs.deleteNonActiveLogFiles();
const files: string[] = await readdir(dir);
const files = await readdir(dir);
expect(files.find(file => file.match(/^log-[0-9]+.txt$/gi))).toBeTruthy();
expect(files.length).toBe(1);
} finally {

View File

@ -29,7 +29,7 @@ export default class RotatingLogs {
const files: Stat[] = await this.fsDriver().readDirStats(this.logFilesDir);
for (const file of files) {
if (!file.path.match(/^log-[0-9]+.txt$/gi)) continue;
const timestamp: string = file.path.match(/[0-9]+/g)[0];
const timestamp: number = parseInt(file.path.match(/[0-9]+/g)[0], 10);
const ageOfTheFile: number = Date.now() - timestamp;
if (ageOfTheFile >= this.inactiveMaxAge) {
await this.fsDriver().remove(this.logFileFullpath(file.path));