IndexedDB deleteDatabase does not reset version

喜夏-厌秋 提交于 2019-12-08 06:54:46

问题


In Firefox. Init (once)

var r, dbname = 'a1', db = mozIndexedDB;

First,

try { r = db.open(dbname, 5); } catch (ex) { console.log(ex); }
r.onupgradeneeded = r.onsuccess = r.onblocked = r.onerror = function (e) { console.log(e); };

you get two events fired as supposed to be. Then close the database,

r.result.close()

Finally, delete the database,

try { r = db.deleteDatabase(dbname); } catch (ex) { console.log(ex); }
r.onsuccess = r.onerror = r.onblocked = function (e) { console.log(e); };

deletes successfully. However when I start running the first step scrip (opening db), 'onupgradeneeded' does not get fired and opens database with version it had before it was deleted. Is it bug, or am I doing smth wrong?

Thanks.


回答1:


You don't seem to be doing anything wrong. For what it's worth, I believe the deleteDatabase implementation is relatively new in FF so perhaps you've found a bug.

One thing I would try is to first inspect and then physically remove the IndexeDB-backing .sqlite database files before restarting the browser. It could be a caching thing. Paths to those files below.

On a PC:

C:\Users\username\AppData\Roaming\Mozilla\Firefox\Profiles\<*>.default\indexedDB

On a Mac:

/Users/username/Library/Application\ Support/Firefox/Profiles/<*>.default/indexedDB/

The table in the .sqlite file that has the database version is called database, and there are two columns, name and version. Your database should be in that table and should list the version number.

Deleting the database should delete that row. If it doesn't, I believe you've found a bug.

Worst comes to worse, delete the entire directory in the indexedDB profile folder and reinstall to verify a fresh install works.



来源:https://stackoverflow.com/questions/11216744/indexeddb-deletedatabase-does-not-reset-version

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!