@fudrouter/fsrouter 0.6.101 → 0.6.102

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -91,9 +91,7 @@ export async function POST_handler(req, res) {
91
91
  const hasLogical = !!body.database;
92
92
  if (hasLogical) {
93
93
  progress(15, "Mengimpor data logical (provider, connections, proxy, api keys, combos)...");
94
- // Import on the live connection — do NOT close it first, or getAdapter()
95
- // would keep returning the stale closed instance and every query throws
96
- // "The database connection is not open".
94
+ // Import on the live connection.
97
95
  await importDb(body.database);
98
96
  progress(40, "Flush WAL ke file database utama (checkpoint)...");
99
97
  const db = await getAdapter();
@@ -111,6 +109,26 @@ export async function POST_handler(req, res) {
111
109
  }
112
110
  catch { /* ignore */ }
113
111
  }
112
+ progress(50, "Menutup koneksi DB agar file WAL/SHM tidak terkunci...");
113
+ // Switch journal mode to DELETE so SQLite folds the WAL back into the
114
+ // main db file and deletes -wal/-shm itself — avoids leaving a locked
115
+ // WAL that Windows can't unlink (which previously dropped restored rows).
116
+ if (db && typeof db.exec === "function") {
117
+ try {
118
+ db.exec("PRAGMA journal_mode=DELETE");
119
+ }
120
+ catch { /* ignore */ }
121
+ }
122
+ // Close the connection so Windows releases the -wal/-shm file locks.
123
+ // Logical data is already flushed to the main DB via the checkpoint above.
124
+ if (db && typeof db.close === "function") {
125
+ try {
126
+ db.close();
127
+ }
128
+ catch { /* ignore */ }
129
+ }
130
+ // Clear the cached instance so getAdapter() re-opens fresh on next boot.
131
+ resetAdapter();
114
132
  }
115
133
  else {
116
134
  progress(15, "Menutup koneksi database aktif (raw restore)...");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fudrouter/fsrouter",
3
- "version": "0.6.101",
3
+ "version": "0.6.102",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "description": "9Router v2 — Express Backend (API, SSE, DB, Auth, MITM)",