supastash 0.2.5 → 0.2.7
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/shared/db/adapters/tauri.d.ts.map +1 -1
- package/dist/shared/db/adapters/tauri.js +4 -0
- package/dist/shared/utils/query/builder/mainQuery.js +1 -1
- package/dist/shared/utils/schema/createSyncStatus.d.ts +5 -3
- package/dist/shared/utils/schema/createSyncStatus.d.ts.map +1 -1
- package/dist/shared/utils/schema/createSyncStatus.js +29 -23
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tauri.d.ts","sourceRoot":"","sources":["../../../../src/shared/db/adapters/tauri.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,sBAAsB,EAEtB,iBAAiB,EAClB,MAAM,mCAAmC,CAAC;AAG3C,eAAO,MAAM,kBAAkB,EAAE,sBAAsB,CAAC,iBAAiB,
|
|
1
|
+
{"version":3,"file":"tauri.d.ts","sourceRoot":"","sources":["../../../../src/shared/db/adapters/tauri.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,sBAAsB,EAEtB,iBAAiB,EAClB,MAAM,mCAAmC,CAAC;AAG3C,eAAO,MAAM,kBAAkB,EAAE,sBAAsB,CAAC,iBAAiB,CAsJxE,CAAC"}
|
|
@@ -2,6 +2,10 @@ import { interpolate, namedToPositional } from "../normalizer";
|
|
|
2
2
|
export const SQLiteAdapterTauri = {
|
|
3
3
|
async openDatabaseAsync(name, sqliteClient) {
|
|
4
4
|
const db = await sqliteClient.load(`sqlite:${name}`);
|
|
5
|
+
// Enable WAL mode for concurrent read/write and set a busy timeout so
|
|
6
|
+
// writers wait instead of immediately returning SQLITE_BUSY (code 5).
|
|
7
|
+
await db.execute("PRAGMA journal_mode=WAL;", []);
|
|
8
|
+
await db.execute("PRAGMA busy_timeout=5000;", []);
|
|
5
9
|
const normalizeParams = (params) => {
|
|
6
10
|
return (params ?? []).map((v) => typeof v === "boolean" ? (v ? 1 : 0) : v);
|
|
7
11
|
};
|
|
@@ -11,9 +11,11 @@ export declare const ADD_PK_TO_SYNC_MARKS_SQL = "\n ALTER TABLE supastash_sync_
|
|
|
11
11
|
export declare const INDEX_SYNC_MARKS_SQL = "\n CREATE INDEX IF NOT EXISTS idx_supastash_marks_updated\n ON supastash_sync_marks(updated_at);\n";
|
|
12
12
|
export declare const INDEX_SERVER_SYNC_MARKS_SQL = "\n CREATE INDEX IF NOT EXISTS idx_supastash_server_marks_updated\n ON supastash_server_sync_marks(updated_at);\n";
|
|
13
13
|
/**
|
|
14
|
-
* Creates the supastash_sync_marks table if it doesn't exist
|
|
15
|
-
*
|
|
16
|
-
*
|
|
14
|
+
* Creates the supastash_sync_marks table if it doesn't exist.
|
|
15
|
+
* Guarded by a singleton promise so concurrent callers share one
|
|
16
|
+
* initialization pass instead of racing on DDL writes.
|
|
17
17
|
*/
|
|
18
18
|
export declare function createSyncStatusTable(): Promise<void>;
|
|
19
|
+
/** Reset the singleton (useful for tests or after closeSupastashDb). */
|
|
20
|
+
export declare function resetSyncStatusTableCache(): void;
|
|
19
21
|
//# sourceMappingURL=createSyncStatus.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createSyncStatus.d.ts","sourceRoot":"","sources":["../../../../src/shared/utils/schema/createSyncStatus.ts"],"names":[],"mappings":"AAGA;;;;;GAKG;AACH,wBAAsB,wBAAwB,kBAE7C;AAED,eAAO,MAAM,sBAAsB,0ZAUhC,CAAC;AAEJ,eAAO,MAAM,6BAA6B,6eAezC,CAAC;AAEF,eAAO,MAAM,wBAAwB,mFAEpC,CAAC;AAEF,eAAO,MAAM,oBAAoB,2GAGhC,CAAC;AAEF,eAAO,MAAM,2BAA2B,yHAGvC,CAAC;AAIF;;;;GAIG;AACH,wBAAsB,qBAAqB,
|
|
1
|
+
{"version":3,"file":"createSyncStatus.d.ts","sourceRoot":"","sources":["../../../../src/shared/utils/schema/createSyncStatus.ts"],"names":[],"mappings":"AAGA;;;;;GAKG;AACH,wBAAsB,wBAAwB,kBAE7C;AAED,eAAO,MAAM,sBAAsB,0ZAUhC,CAAC;AAEJ,eAAO,MAAM,6BAA6B,6eAezC,CAAC;AAEF,eAAO,MAAM,wBAAwB,mFAEpC,CAAC;AAEF,eAAO,MAAM,oBAAoB,2GAGhC,CAAC;AAEF,eAAO,MAAM,2BAA2B,yHAGvC,CAAC;AAIF;;;;GAIG;AACH,wBAAsB,qBAAqB,kBAuB1C;AAED,wEAAwE;AACxE,wBAAgB,yBAAyB,SAExC"}
|
|
@@ -47,30 +47,36 @@ export const INDEX_SERVER_SYNC_MARKS_SQL = `
|
|
|
47
47
|
CREATE INDEX IF NOT EXISTS idx_supastash_server_marks_updated
|
|
48
48
|
ON supastash_server_sync_marks(updated_at);
|
|
49
49
|
`;
|
|
50
|
-
let
|
|
50
|
+
let syncStatusTablePromise = null;
|
|
51
51
|
/**
|
|
52
|
-
* Creates the supastash_sync_marks table if it doesn't exist
|
|
53
|
-
*
|
|
54
|
-
*
|
|
52
|
+
* Creates the supastash_sync_marks table if it doesn't exist.
|
|
53
|
+
* Guarded by a singleton promise so concurrent callers share one
|
|
54
|
+
* initialization pass instead of racing on DDL writes.
|
|
55
55
|
*/
|
|
56
56
|
export async function createSyncStatusTable() {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
await
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
57
|
+
if (syncStatusTablePromise)
|
|
58
|
+
return syncStatusTablePromise;
|
|
59
|
+
syncStatusTablePromise = (async () => {
|
|
60
|
+
const db = await getSupastashDb();
|
|
61
|
+
const cfg = getSupastashConfig();
|
|
62
|
+
if (cfg.replicationMode === "server-side") {
|
|
63
|
+
await db.execAsync(SERVER_SYNC_STATUS_TABLES_SQL);
|
|
64
|
+
await db.execAsync(INDEX_SERVER_SYNC_MARKS_SQL);
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
await db.execAsync(SYNC_STATUS_TABLES_SQL);
|
|
68
|
+
await db.execAsync(INDEX_SYNC_MARKS_SQL);
|
|
69
|
+
}
|
|
70
|
+
try {
|
|
71
|
+
await db.execAsync(ADD_PK_TO_SYNC_MARKS_SQL);
|
|
72
|
+
}
|
|
73
|
+
catch {
|
|
74
|
+
// Ignore — column already exists
|
|
75
|
+
}
|
|
76
|
+
})();
|
|
77
|
+
return syncStatusTablePromise;
|
|
78
|
+
}
|
|
79
|
+
/** Reset the singleton (useful for tests or after closeSupastashDb). */
|
|
80
|
+
export function resetSyncStatusTableCache() {
|
|
81
|
+
syncStatusTablePromise = null;
|
|
76
82
|
}
|