Commit 6b04cb82 authored by Roque's avatar Roque

Only force reconfig for old app versions

See merge request nexedi/erp5!1998
parents 5d126a25 f63dcfc7
...@@ -10,23 +10,20 @@ ...@@ -10,23 +10,20 @@
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
.declareAcquiredMethod("redirect", "redirect") .declareAcquiredMethod("redirect", "redirect")
.declareAcquiredMethod("jio_remove", "jio_remove") .declareAcquiredMethod("jio_remove", "jio_remove")
.declareAcquiredMethod("notifySubmitting", "notifySubmitting")
.declareAcquiredMethod("notifySubmitted", 'notifySubmitted') .declareAcquiredMethod("notifySubmitted", 'notifySubmitted')
.declareMethod("render", function (options) { .declareMethod("render", function (options) {
var gadget = this; var gadget = this;
return gadget.jio_remove(options.jio_key)
return gadget.notifySubmitting()
.push(function () {
return gadget.jio_remove(options.jio_key);
})
.push(function () { .push(function () {
return gadget.notifySubmitted({message: "Document Deleted", status: "success"}); return gadget.notifySubmitted({message: "Document Deleted", status: "success"})
}, function (error) {
return gadget.notifySubmitted({message: error.message, status: "error"})
}) })
.push(function () { .push(function () {
return gadget.redirect({command: 'change', options: { return gadget.redirect({command: 'change', options: {
page: options.return_url || 'settings_configurator' page: options.return_url || 'settings_configurator'
}}); }});
}); });
}); }, {mutex: 'render'});
}(window, rJS)); }(window, rJS));
...@@ -260,7 +260,7 @@ ...@@ -260,7 +260,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>1016.7854.16646.24046</string> </value> <value> <string>1020.22291.41890.38485</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -280,7 +280,7 @@ ...@@ -280,7 +280,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1713981022.38</float> <float>1730318970.28</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -120,8 +120,8 @@ ...@@ -120,8 +120,8 @@
.declareAcquiredMethod("setSettingList", "setSettingList") .declareAcquiredMethod("setSettingList", "setSettingList")
.declareAcquiredMethod("setSetting", "setSetting") .declareAcquiredMethod("setSetting", "setSetting")
.declareMethod('updateConfiguration', function (appcache_storage, current_version, jio_storage) { .declareMethod('updateConfiguration', function (appcache_storage, current_version, jio_storage, force_reconfig) {
var gadget = this; var gadget = this, setting_dict = {'migration_version': current_version};
if (!appcache_storage) { return; } if (!appcache_storage) { return; }
return RSVP.Queue() return RSVP.Queue()
.push(function () { .push(function () {
...@@ -131,9 +131,11 @@ ...@@ -131,9 +131,11 @@
return jio_storage.repair(); return jio_storage.repair();
}) })
.push(function () { .push(function () {
return gadget.setSettingList({'migration_version': current_version, if (force_reconfig) {
'master_url_list': undefined, setting_dict.master_url_list = undefined;
'master_url_list_updated': false}); setting_dict.master_url_list_updated = false;
}
return gadget.setSettingList(setting_dict);
}); });
}) })
...@@ -149,7 +151,7 @@ ...@@ -149,7 +151,7 @@
.declareMethod('createJio', function (options) { .declareMethod('createJio', function (options) {
var gadget = this, current_version, index, appcache_storage, var gadget = this, current_version, index, appcache_storage,
appcache_jio, migration_version, manifest, monitoring_jio, appcache_jio, migration_version, manifest, monitoring_jio,
origin_url = window.location.href; origin_url = window.location.href, force_reconfig = false;
return gadget.getSettingList(['configuration_manifest', return gadget.getSettingList(['configuration_manifest',
'migration_version']) 'migration_version'])
.push(function (result_list) { .push(function (result_list) {
...@@ -207,37 +209,51 @@ ...@@ -207,37 +209,51 @@
}; };
return gadget.createStorage(options, monitoring_jio); return gadget.createStorage(options, monitoring_jio);
}) })
//backward compatibility: old app versions had badnamed data
.push(function () { .push(function () {
if (migration_version !== current_version) { if (migration_version !== current_version) {
if (gadget.props.jio_storage) { if (gadget.props.jio_storage) {
return gadget.props.jio_storage.allDocs(); return gadget.props.jio_storage.allDocs({
query: '(portal_type:promise)'
});
} }
} }
}) })
.push(function (all_docs) { .push(function (result) {
var remove_queue = new RSVP.Queue(), i; function remove_all() {
function remove_doc(id) { return gadget.props.jio_storage.allDocs()
remove_queue .push(function (all_docs) {
.push(function () { var remove_queue = new RSVP.Queue(), i;
return gadget.props.jio_storage.remove(id); function remove_doc(id) {
remove_queue
.push(function () {
return gadget.props.jio_storage.remove(id);
});
}
if (all_docs && all_docs.data.total_rows) {
//iterate all docs, jio_remove, and recreate
for (i = 0; i < all_docs.data.total_rows; i += 1) {
remove_doc(all_docs.data.rows[i].id);
}
return RSVP.all([
remove_queue,
gadget.createStorage(options, monitoring_jio),
gadget.setSetting("latest_import_date", undefined)
]);
}
}); });
} }
if (all_docs && all_docs.data.total_rows) { if (result && result.data.rows.length > 0) {
//iterate all docs, jio_remove, and recreate force_reconfig = true;
for (i = 0; i < all_docs.data.total_rows; i += 1) { if (gadget.props.jio_storage) {
remove_doc(all_docs.data.rows[i].id); return remove_all();
} }
return RSVP.all([
remove_queue,
gadget.createStorage(options, monitoring_jio),
gadget.setSetting("latest_import_date", undefined)
]);
} }
}) })
.push(function () { .push(function () {
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, current_version, gadget.props.jio_storage); return gadget.updateConfiguration(appcache_storage, current_version, gadget.props.jio_storage, force_reconfig);
} }
}) })
.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>1019.25813.42370.5614</string> </value> <value> <string>1020.20652.1827.11417</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>1726682335.1</float> <float>1730218508.62</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -257,6 +257,13 @@ ...@@ -257,6 +257,13 @@
}); });
} }
return removeOPMLTree(id); return removeOPMLTree(id);
}, function (error) {
if (error && error.status_code === 404) {
//opml already removed
return;
} else {
throw error;
}
}); });
}; };
......
...@@ -269,7 +269,7 @@ ...@@ -269,7 +269,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1727445979.03</float> <float>1730318820.81</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -104,7 +104,7 @@ ...@@ -104,7 +104,7 @@
<dictionary> <dictionary>
<item> <item>
<key> <string>_defined_in_class</string> </key> <key> <string>_defined_in_class</string> </key>
<value> <bool>True</bool> </value> <value> <int>1</int> </value>
</item> </item>
<item> <item>
<key> <string>_hookname</string> </key> <key> <string>_hookname</string> </key>
...@@ -544,7 +544,7 @@ ...@@ -544,7 +544,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>1015.32811.46439.54528</string> </value> <value> <string>1019.37281.47800.48247</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -564,7 +564,7 @@ ...@@ -564,7 +564,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1716562039.61</float> <float>1730218552.03</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -104,7 +104,7 @@ ...@@ -104,7 +104,7 @@
<dictionary> <dictionary>
<item> <item>
<key> <string>_defined_in_class</string> </key> <key> <string>_defined_in_class</string> </key>
<value> <bool>True</bool> </value> <value> <int>1</int> </value>
</item> </item>
<item> <item>
<key> <string>_hookname</string> </key> <key> <string>_hookname</string> </key>
...@@ -579,7 +579,7 @@ WebSection_getMonitorPrecacheManifestList</string> </value> ...@@ -579,7 +579,7 @@ WebSection_getMonitorPrecacheManifestList</string> </value>
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>1015.45944.11619.35208</string> </value> <value> <string>1019.37281.53022.31078</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -599,7 +599,7 @@ WebSection_getMonitorPrecacheManifestList</string> </value> ...@@ -599,7 +599,7 @@ WebSection_getMonitorPrecacheManifestList</string> </value>
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1716562039.61</float> <float>1730218556.13</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -69,7 +69,7 @@ ...@@ -69,7 +69,7 @@
<dictionary> <dictionary>
<item> <item>
<key> <string>_defined_in_class</string> </key> <key> <string>_defined_in_class</string> </key>
<value> <bool>True</bool> </value> <value> <int>1</int> </value>
</item> </item>
<item> <item>
<key> <string>_hookname</string> </key> <key> <string>_hookname</string> </key>
...@@ -339,7 +339,7 @@ ...@@ -339,7 +339,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>1014.3364.27014.642380</string> </value> <value> <string>1019.25707.33677.14080</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -359,7 +359,7 @@ ...@@ -359,7 +359,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1716562039.61</float> <float>1730218552.03</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