You've already forked matrix-js-sdk
mirror of
https://github.com/matrix-org/matrix-js-sdk.git
synced 2025-11-29 16:43:09 +03:00
Treat errors when deleting indexeddb as non-fatal
If we get an error when vaping the indexeddb, carry on regardless
This commit is contained in:
@@ -116,9 +116,11 @@ export default class IndexedDBCryptoStore {
|
|||||||
};
|
};
|
||||||
|
|
||||||
req.onerror = (ev) => {
|
req.onerror = (ev) => {
|
||||||
reject(new Error(
|
// in firefox, with indexedDB disabled, this fails with a
|
||||||
"unable to delete indexeddb: " + ev.target.error,
|
// DOMError. We treat this as non-fatal, so that people can
|
||||||
));
|
// still use the app.
|
||||||
|
console.warn(`unable to delete IndexedDBCryptoStore: ${ev.target.error}`);
|
||||||
|
resolve();
|
||||||
};
|
};
|
||||||
|
|
||||||
req.onsuccess = () => {
|
req.onsuccess = () => {
|
||||||
|
|||||||
@@ -163,8 +163,32 @@ LocalIndexedDBStoreBackend.prototype = {
|
|||||||
* @return {Promise} Resolved when the database is cleared.
|
* @return {Promise} Resolved when the database is cleared.
|
||||||
*/
|
*/
|
||||||
clearDatabase: function() {
|
clearDatabase: function() {
|
||||||
console.log("Removing indexeddb instance: ", this._dbName);
|
return new q.Promise((resolve, reject) => {
|
||||||
return promiseifyRequest(this.indexedDB.deleteDatabase(this._dbName));
|
console.log(`Removing indexeddb instance: ${this._dbName}`);
|
||||||
|
const req = this.indexedDB.deleteDatabase(this._dbName);
|
||||||
|
|
||||||
|
req.onblocked = () => {
|
||||||
|
console.log(
|
||||||
|
`can't yet delete indexeddb ${this._dbName}` +
|
||||||
|
` because it is open elsewhere`,
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
req.onerror = (ev) => {
|
||||||
|
// in firefox, with indexedDB disabled, this fails with a
|
||||||
|
// DOMError. We treat this as non-fatal, so that we can still
|
||||||
|
// use the app.
|
||||||
|
console.warn(
|
||||||
|
`unable to delete js-sdk store indexeddb: ${ev.target.error}`,
|
||||||
|
);
|
||||||
|
resolve();
|
||||||
|
};
|
||||||
|
|
||||||
|
req.onsuccess = () => {
|
||||||
|
console.log(`Removed indexeddb instance: ${this._dbName}`);
|
||||||
|
resolve();
|
||||||
|
};
|
||||||
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user