issue 102 Do something reasonable if the Stylish DB can't be read

This commit is contained in:
Jason Barnabe 2013-06-25 23:25:04 -05:00
parent b7aa8b4b81
commit 2064f56796
6 changed files with 22 additions and 1 deletions

View File

@ -72,6 +72,10 @@
"message": "Checking...",
"description": "Text to display when checking a style for an update"
},
"dbError": {
"message": "An error has occurred using the Stylish database. Would you like to visit a web page with possible solutions?",
"description": "Prompt when a DB error is encountered"
},
"deleteStyleLabel": {
"message": "Delete",
"description": "Label for the button to delete a style"

View File

@ -21,6 +21,9 @@ chrome.extension.onMessage.addListener(function(request, sender, sendResponse) {
case "styleChanged":
cachedStyles = null;
break;
case "healthCheck":
getDatabase(function() { sendResponse(true); }, function() { sendResponse(false); });
break;
}
});

7
health.js Normal file
View File

@ -0,0 +1,7 @@
chrome.extension.sendMessage({method: "healthCheck"}, function(ok) {
if (!ok) {
if (confirm(t("dbError"))) {
window.open("http://userstyles.org/dberror");
}
}
});

View File

@ -85,6 +85,7 @@
}
</style>
<script src="localization.js"></script>
<script src="health.js"></script>
<script src="storage.js"></script>
<script src="messaging.js"></script>
</head>

View File

@ -39,6 +39,7 @@
</style>
<script src="localization.js"></script>
<script src="health.js"></script>
<script src="storage.js"></script>
<script src="messaging.js"></script>
</head>

View File

@ -4,7 +4,12 @@ function getDatabase(ready, error) {
ready(stylishDb);
return;
}
stylishDb = openDatabase('stylish', '', 'Stylish Styles', 5*1024*1024);
try {
stylishDb = openDatabase('stylish', '', 'Stylish Styles', 5*1024*1024);
} catch (ex) {
error();
throw ex;
}
if (stylishDb.version == "1.0" || stylishDb.version == "") {
dbV11(stylishDb, error, ready);
} else if (stylishDb.version == "1.1") {