|
|
@@ -206,6 +206,8 @@ function createSqliteStore({ file }) {
|
|
|
try {
|
|
|
const result = await fn({ insertUpload, upsertRows, upsertShops, deleteRowsByUpload, updateReport });
|
|
|
handle.exec('COMMIT');
|
|
|
+ // 写事务结束后做一次 checkpoint:让 data/ops.db 自包含,备份时不必关心 -wal
|
|
|
+ try { handle.exec('PRAGMA wal_checkpoint(TRUNCATE)'); } catch { /* 有读事务时跳过 */ }
|
|
|
return result;
|
|
|
} catch (e) {
|
|
|
try { handle.exec('ROLLBACK'); } catch { /* 事务可能已结束 */ }
|
|
|
@@ -301,6 +303,7 @@ function createSqliteStore({ file }) {
|
|
|
|
|
|
async function close() {
|
|
|
if (db) {
|
|
|
+ try { db.exec('PRAGMA wal_checkpoint(TRUNCATE)'); } catch { /* ignore */ }
|
|
|
try { db.close(); } catch { /* ignore */ }
|
|
|
db = null;
|
|
|
initPromise = null;
|