Skip to content

Commit 99a1b6b

Browse files
authored
fix: run compaction every interval (#834)
1 parent 059c3b4 commit 99a1b6b

File tree

4 files changed

+8
-0
lines changed

4 files changed

+8
-0
lines changed

server/models/Users.ts

+1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ class Users {
3131
});
3232

3333
db.ensureIndex({fieldName: 'username', unique: true});
34+
db.setAutocompactionInterval(config.dbCleanInterval);
3435

3536
return db;
3637
})();

server/services/feedService.ts

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ class FeedService extends BaseService<Record<string, never>> {
2121

2222
constructor(...args: ConstructorParameters<typeof BaseService>) {
2323
super(...args);
24+
this.db.setAutocompactionInterval(config.dbCleanInterval);
2425

2526
this.onServicesUpdated = async () => {
2627
// Execute once only.

server/services/notificationService.ts

+1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ class NotificationService extends BaseService<NotificationServiceEvents> {
2626

2727
constructor(...args: ConstructorParameters<typeof BaseService>) {
2828
super(...args);
29+
this.db.setAutocompactionInterval(config.dbCleanInterval);
2930

3031
(async () => {
3132
const notifications = await this.db.findAsync<Notification>({}).catch(() => undefined);

server/services/settingService.ts

+5
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@ class SettingService extends BaseService<SettingServiceEvents> {
2121
filename: path.join(config.dbPath, this.user._id, 'settings', 'settings.db'),
2222
});
2323

24+
constructor(...args: ConstructorParameters<typeof BaseService>) {
25+
super(...args);
26+
this.db.setAutocompactionInterval(config.dbCleanInterval);
27+
}
28+
2429
async destroy(drop: boolean) {
2530
if (drop) {
2631
await this.db.dropDatabaseAsync();

0 commit comments

Comments
 (0)