Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

core: use bulk io operations for logger storage

Abdullah Atta5a001a145747
diff --git a/packages/core/src/logger.js b/packages/core/src/logger.js
index bcd0bb1a6..82bd6513a 100644
--- a/packages/core/src/logger.js
+++ b/packages/core/src/logger.js
@@ -79,21 +79,19 @@ class DatabaseLogWriter {
async read() {
const logKeys = await this.storage.getAllKeys();
- const logs = [];
+ const keys = [];
for (let key of logKeys) {
- if (key.startsWith(this.key)) logs.push(await this.storage.read(key));
+ if (key.startsWith(this.key)) keys.push(key);
}
- return logs;
+ return Object.values(await this.storage.readMulti(keys));
}
async flush() {
if (Object.keys(this.queue).length === 0) return;
- const queueCopy = { ...this.queue };
+ const queueCopy = Object.entries(this.queue);
this.queue = {};
- for (let key in queueCopy) {
- await this.storage.write(key, queueCopy[key]);
- }
+ await this.storage.writeMulti(queueCopy);
}
async rotate() {