summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Yatskov <alex@foosoft.net>2016-12-30 10:47:27 -0800
committerAlex Yatskov <alex@foosoft.net>2016-12-30 10:47:27 -0800
commit9dfafe9d26a63fac404afded0f3d362483dc7c60 (patch)
tree87058934acd394d2777c0e6b58b6cc1dabcd08b3
parent80225a00d337b9fde94bb65681632d6b04a7bcfc (diff)
purge old database versions1.0.1
-rw-r--r--ext/bg/js/database.js29
-rw-r--r--ext/manifest.json2
2 files changed, 22 insertions, 9 deletions
diff --git a/ext/bg/js/database.js b/ext/bg/js/database.js
index a21708f5..9fb45794 100644
--- a/ext/bg/js/database.js
+++ b/ext/bg/js/database.js
@@ -20,23 +20,36 @@
class Database {
constructor() {
this.db = null;
+ this.dbVersion = 1;
this.tagMetaCache = {};
}
+ sanitize() {
+ const db = new Dexie('dict');
+ return db.open().then(() => {
+ db.close();
+ if (db.verno !== this.dbVersion) {
+ return db.delete();
+ }
+ }).catch(() => {});
+ }
+
prepare() {
if (this.db !== null) {
return Promise.reject('database already initialized');
}
- this.db = new Dexie('dict');
- this.db.version(1).stores({
- terms: '++id,dictionary,expression,reading',
- kanji: '++,dictionary,character',
- tagMeta: '++,dictionary',
- dictionaries: '++,title,version',
- });
+ return this.sanitize().then(() => {
+ this.db = new Dexie('dict');
+ this.db.version(this.dbVersion).stores({
+ terms: '++id,dictionary,expression,reading',
+ kanji: '++,dictionary,character',
+ tagMeta: '++,dictionary',
+ dictionaries: '++,title,version',
+ });
- return this.db.open();
+ return this.db.open();
+ });
}
purge() {
diff --git a/ext/manifest.json b/ext/manifest.json
index 86908f0e..c7c1ffa9 100644
--- a/ext/manifest.json
+++ b/ext/manifest.json
@@ -1,7 +1,7 @@
{
"manifest_version": 2,
"name": "Yomichan",
- "version": "1.0.0",
+ "version": "1.0.1",
"description": "Japanese dictionary with Anki integration",
"icons": {"16": "img/icon16.png", "48": "img/icon48.png", "128": "img/icon128.png"},