Skip to content

Commit 6e4e929

Browse files
committed
refactor: rename to retentionGB
1 parent b638b34 commit 6e4e929

File tree

2 files changed

+7
-11
lines changed

2 files changed

+7
-11
lines changed

packages/mongodb-log-writer/src/mongo-log-manager.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ describe('MongoLogManager', function () {
130130
retentionDays,
131131
maxLogFileCount: 1000,
132132
// 6 KB
133-
logRetentionGB: 6 / 1024 / 1024,
133+
retentionGB: 6 / 1024 / 1024,
134134
onwarn,
135135
onerror,
136136
});

packages/mongodb-log-writer/src/mongo-log-manager.ts

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ interface MongoLogOptions {
1818
/** The maximal number of log files which are kept. */
1919
maxLogFileCount?: number;
2020
/** The maximal GB of log files which are kept. */
21-
logRetentionGB?: number;
21+
retentionGB?: number;
2222
/** A handler for warnings related to a specific filesystem path. */
2323
onerror: (err: Error, path: string) => unknown | Promise<void>;
2424
/** A handler for errors related to a specific filesystem path. */
@@ -59,11 +59,10 @@ export class MongoLogManager {
5959
fileSize?: number;
6060
}>((a, b) => a.fileTimestamp - b.fileTimestamp);
6161

62-
const storageSizeLimit = this._options.logRetentionGB
63-
? this._options.logRetentionGB * 1024 * 1024 * 1024
62+
const storageSizeLimit = this._options.retentionGB
63+
? this._options.retentionGB * 1024 * 1024 * 1024
6464
: Infinity;
65-
let usedStorageSize = this._options.logRetentionGB ? 0 : -Infinity;
66-
// eslint-disable-next-line no-console
65+
let usedStorageSize = this._options.retentionGB ? 0 : -Infinity;
6766

6867
for await (const dirent of dirHandle) {
6968
// Cap the overall time spent inside this function. Consider situations like
@@ -94,12 +93,9 @@ export class MongoLogManager {
9493
toDelete = {
9594
fullPath,
9695
};
97-
} else if (
98-
this._options.logRetentionGB ||
99-
this._options.maxLogFileCount
100-
) {
96+
} else if (this._options.retentionGB || this._options.maxLogFileCount) {
10197
const fileSize = (await fs.stat(fullPath)).size;
102-
if (this._options.logRetentionGB) {
98+
if (this._options.retentionGB) {
10399
usedStorageSize += fileSize;
104100
}
105101

0 commit comments

Comments
 (0)