Небольшие доработки

This commit is contained in:
Book Pauk
2019-03-20 12:30:13 +07:00
parent e626cb6b40
commit f9d8b37b1a
3 changed files with 13 additions and 3 deletions

View File

@@ -84,11 +84,19 @@ class ReaderStorage {
}
const dbh = await this.storagePool.get();
await dbh.run('BEGIN');
try {
const newRev = {};
for (const id of Object.keys(items)) {
await dbh.run(SQL`INSERT OR REPLACE INTO storage (id, rev, time, data) VALUES (${id}, ${items[id].rev}, strftime('%s','now'), ${items[id].data})`);
this.cache[id] = {rev: items[id].rev};
newRev[id] = {rev: items[id].rev};
}
await dbh.run('COMMIT');
Object.assign(this.cache, newRev);
} catch (e) {
await dbh.run('ROLLBACK');
throw e;
} finally {
dbh.ret();
}