mirror of
https://github.com/zoriya/flood.git
synced 2025-12-05 23:06:20 +00:00
fix: run compaction every interval (#834)
This commit is contained in:
@@ -31,6 +31,7 @@ class Users {
|
|||||||
});
|
});
|
||||||
|
|
||||||
db.ensureIndex({fieldName: 'username', unique: true});
|
db.ensureIndex({fieldName: 'username', unique: true});
|
||||||
|
db.setAutocompactionInterval(config.dbCleanInterval);
|
||||||
|
|
||||||
return db;
|
return db;
|
||||||
})();
|
})();
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ class FeedService extends BaseService<Record<string, never>> {
|
|||||||
|
|
||||||
constructor(...args: ConstructorParameters<typeof BaseService>) {
|
constructor(...args: ConstructorParameters<typeof BaseService>) {
|
||||||
super(...args);
|
super(...args);
|
||||||
|
this.db.setAutocompactionInterval(config.dbCleanInterval);
|
||||||
|
|
||||||
this.onServicesUpdated = async () => {
|
this.onServicesUpdated = async () => {
|
||||||
// Execute once only.
|
// Execute once only.
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ class NotificationService extends BaseService<NotificationServiceEvents> {
|
|||||||
|
|
||||||
constructor(...args: ConstructorParameters<typeof BaseService>) {
|
constructor(...args: ConstructorParameters<typeof BaseService>) {
|
||||||
super(...args);
|
super(...args);
|
||||||
|
this.db.setAutocompactionInterval(config.dbCleanInterval);
|
||||||
|
|
||||||
(async () => {
|
(async () => {
|
||||||
const notifications = await this.db.findAsync<Notification>({}).catch(() => undefined);
|
const notifications = await this.db.findAsync<Notification>({}).catch(() => undefined);
|
||||||
|
|||||||
@@ -21,6 +21,11 @@ class SettingService extends BaseService<SettingServiceEvents> {
|
|||||||
filename: path.join(config.dbPath, this.user._id, 'settings', 'settings.db'),
|
filename: path.join(config.dbPath, this.user._id, 'settings', 'settings.db'),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
constructor(...args: ConstructorParameters<typeof BaseService>) {
|
||||||
|
super(...args);
|
||||||
|
this.db.setAutocompactionInterval(config.dbCleanInterval);
|
||||||
|
}
|
||||||
|
|
||||||
async destroy(drop: boolean) {
|
async destroy(drop: boolean) {
|
||||||
if (drop) {
|
if (drop) {
|
||||||
await this.db.dropDatabaseAsync();
|
await this.db.dropDatabaseAsync();
|
||||||
|
|||||||
Reference in New Issue
Block a user