Changeset View
Changeset View
Standalone View
Standalone View
web/database/worker/db-worker.js
Show First 20 Lines • Show All 165 Lines • ▼ Show 20 Lines | ) { | ||||
await localforage.setItem(SQLITE_ENCRYPTION_KEY, cryptoKey); | await localforage.setItem(SQLITE_ENCRYPTION_KEY, cryptoKey); | ||||
return; | return; | ||||
} | } | ||||
// database operations | // database operations | ||||
if (message.type === workerRequestMessageTypes.INIT) { | if (message.type === workerRequestMessageTypes.INIT) { | ||||
await initDatabase(message.sqljsFilePath, message.sqljsFilename); | await initDatabase(message.sqljsFilePath, message.sqljsFilename); | ||||
return; | return; | ||||
} else if (message.type === workerRequestMessageTypes.CLEAR_SENSITIVE_DATA) { | |||||
encryptionKey = null; | |||||
if (sqliteDb) { | |||||
sqliteDb.close(); | |||||
} | |||||
await localforage.clear(); | |||||
marcin: A typical question: can this throw or fail and if so - should we handle such situation? | |||||
kamilAuthorUnsubmitted Done Inline Actionsit will propagate from worker to worker proxy, then to the database module provider, and then the caller should handle this - in that case, it's in sqlite-data-handler kamil: it will propagate from worker to worker proxy, then to the database module provider, and then… | |||||
return; | |||||
} | } | ||||
if (!sqliteDb) { | if (!sqliteDb) { | ||||
throw new Error('Database not initialized'); | throw new Error('Database not initialized'); | ||||
} | } | ||||
// read-only operations | // read-only operations | ||||
if (message.type === workerRequestMessageTypes.GET_CLIENT_STORE) { | if (message.type === workerRequestMessageTypes.GET_CLIENT_STORE) { | ||||
▲ Show 20 Lines • Show All 80 Lines • Show Last 20 Lines |
A typical question: can this throw or fail and if so - should we handle such situation?