Commit 9a84f1f3 authored by Roque's avatar Roque

erp5_web_monitoring: refine storage update on new app version

parent 01bd4c5a
...@@ -62,13 +62,16 @@ ...@@ -62,13 +62,16 @@
.declareAcquiredMethod("getSettingList", "getSettingList") .declareAcquiredMethod("getSettingList", "getSettingList")
.declareAcquiredMethod("setSetting", "setSetting") .declareAcquiredMethod("setSetting", "setSetting")
.declareMethod('updateConfiguration', function (appcache_storage, migration_version, current_version) { .declareMethod('updateConfiguration', function (appcache_storage, migration_version, current_version, jio_storage) {
var gadget = this; var gadget = this;
if (!appcache_storage) { return; } if (!appcache_storage) { return; }
return RSVP.Queue() return RSVP.Queue()
.push(function () { .push(function () {
return appcache_storage.repair(current_version); return appcache_storage.repair(current_version);
}) })
.push(function () {
return jio_storage.repair();
})
.push(function () { .push(function () {
return gadget.setSetting("migration_version", current_version); return gadget.setSetting("migration_version", current_version);
}); });
...@@ -83,6 +86,14 @@ ...@@ -83,6 +86,14 @@
.push(function (result_list) { .push(function (result_list) {
//TODO fix missing router setting (it's set but get returns undefined) //TODO fix missing router setting (it's set but get returns undefined)
migration_version = result_list[1]; migration_version = result_list[1];
current_version = window.location.href.replace(window.location.hash, "");
index = current_version.indexOf(window.location.host) + window.location.host.length;
current_version = current_version.substr(index);
if (migration_version !== current_version) {
//XXX is this a dirty hack?
indexedDB.deleteDatabase('monitoring-configuration-hash');
indexedDB.deleteDatabase('monitoring_local.db');
}
manifest = "gadget_officejs_monitoring.configuration"; manifest = "gadget_officejs_monitoring.configuration";
if (options !== undefined) { if (options !== undefined) {
gadget.props.jio_storage = jIO.createJIO(options); gadget.props.jio_storage = jIO.createJIO(options);
...@@ -141,12 +152,9 @@ ...@@ -141,12 +152,9 @@
}; };
gadget.props.jio_storage = jIO.createJIO(monitoring_jio); gadget.props.jio_storage = jIO.createJIO(monitoring_jio);
} }
current_version = window.location.href.replace(window.location.hash, "");
index = current_version.indexOf(window.location.host) + window.location.host.length;
current_version = current_version.substr(index);
if (migration_version !== current_version) { if (migration_version !== current_version) {
appcache_storage = jIO.createJIO(appcache_jio); appcache_storage = jIO.createJIO(appcache_jio);
return gadget.updateConfiguration(appcache_storage, migration_version, current_version); return gadget.updateConfiguration(appcache_storage, migration_version, current_version, gadget.props.jio_storage);
} }
}) })
.push(function () { .push(function () {
......
...@@ -249,7 +249,7 @@ ...@@ -249,7 +249,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>1015.22775.37961.58163</string> </value> <value> <string>1015.31731.39115.52974</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -269,7 +269,7 @@ ...@@ -269,7 +269,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1710945940.66</float> <float>1711481527.41</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment