zam-core 0.3.2 → 0.3.3
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.
- package/dist/cli/index.js +13 -7
- package/dist/cli/index.js.map +1 -1
- package/dist/index.js +13 -7
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/cli/index.js
CHANGED
|
@@ -136,18 +136,24 @@ function openDatabase(options = {}) {
|
|
|
136
136
|
const dbOpts = {};
|
|
137
137
|
if (options.syncUrl) {
|
|
138
138
|
dbOpts.syncUrl = options.syncUrl;
|
|
139
|
-
|
|
140
|
-
|
|
139
|
+
}
|
|
140
|
+
if (options.authToken) {
|
|
141
|
+
dbOpts.authToken = options.authToken;
|
|
142
|
+
}
|
|
143
|
+
let db;
|
|
144
|
+
try {
|
|
145
|
+
db = new Database(dbPath, dbOpts);
|
|
146
|
+
} catch (err) {
|
|
147
|
+
if (options.syncUrl && err.message?.includes("InvalidLocalState")) {
|
|
141
148
|
for (const suffix of ["", "-wal", "-shm"]) {
|
|
142
149
|
const f = `${dbPath}${suffix}`;
|
|
143
|
-
if (existsSync(f)) rmSync(f);
|
|
150
|
+
if (existsSync(f)) rmSync(f, { force: true });
|
|
144
151
|
}
|
|
152
|
+
db = new Database(dbPath, dbOpts);
|
|
153
|
+
} else {
|
|
154
|
+
throw err;
|
|
145
155
|
}
|
|
146
156
|
}
|
|
147
|
-
if (options.authToken) {
|
|
148
|
-
dbOpts.authToken = options.authToken;
|
|
149
|
-
}
|
|
150
|
-
const db = new Database(dbPath, dbOpts);
|
|
151
157
|
db.pragma("journal_mode = WAL");
|
|
152
158
|
db.pragma("foreign_keys = ON");
|
|
153
159
|
db.pragma("busy_timeout = 5000");
|