Commit 1100d054 authored by Alain Takoudjou's avatar Alain Takoudjou

erp5_web_mynij_search: Fix seeding when Source is not built and show source...

erp5_web_mynij_search: Fix seeding when Source is not built and show source when there is no magnet uri
parent 996f19b9
...@@ -7,8 +7,8 @@ ...@@ -7,8 +7,8 @@
.declareMethod('render', function (options) { .declareMethod('render', function (options) {
var state_dict = { var state_dict = {
href: options.value || options.default, href: options.value || options.default || "",
alt: options.description || options.key alt: options.description || options.key || ""
}; };
return this.changeState(state_dict); return this.changeState(state_dict);
}) })
...@@ -25,6 +25,8 @@ ...@@ -25,6 +25,8 @@
while (gadget.element.firstChild) { while (gadget.element.firstChild) {
gadget.element.removeChild(gadget.element.lastChild); gadget.element.removeChild(gadget.element.lastChild);
} }
if (!gadget.state.href)
return;
gadget.element.append(link); gadget.element.append(link);
}) })
......
...@@ -234,7 +234,7 @@ ...@@ -234,7 +234,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>995.16010.44333.13482</string> </value> <value> <string>995.16964.34495.18124</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -252,7 +252,7 @@ ...@@ -252,7 +252,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1633363899.54</float> <float>1633421737.53</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -557,16 +557,34 @@ ...@@ -557,16 +557,34 @@
}, },
on_torrent on_torrent
); );
})
.push(undefined, function (err) {
console.error(err);
if (gadget.state.seed_index.hasOwnProperty(id)) {
delete gadget.state.seed_index[id];
}
return gadget.notifySubmitted({
message: "Failed to create torrent blob\n" +
"Make sure your source is built!",
status: "error"
});
}); });
}) })
.declareJob("seedAll", function () { .declareJob("seedAll", function () {
var gadget = this; var gadget = this;
function notify(msg, status) {
return gadget.notifySubmitted({
message: msg,
status: status || "error"
});
}
function seedTorrent() { function seedTorrent() {
return gadget.jio_allDocs({ return gadget.jio_allDocs({
query: 'portal_type: "Mynij Search Collection"', query: 'portal_type: "Mynij Search Collection"',
"select_list": ["title", "seed"] "select_list": ["title", "seed", "status"]
}) })
.push(function (result_list) { .push(function (result_list) {
var i, var i,
...@@ -575,6 +593,12 @@ ...@@ -575,6 +593,12 @@
console.log(result_list); console.log(result_list);
for (i = 0; i < result_list.data.rows.length; i += 1) { for (i = 0; i < result_list.data.rows.length; i += 1) {
let item = result_list.data.rows[i]; let item = result_list.data.rows[i];
if (item.value.status !== "built") {
promise_list.push(
notify("Cannot seed '" + item.value.title +
"', the source is not built!"));
continue;
}
if (item.value.seed === "on" && if (item.value.seed === "on" &&
!gadget.state.seed_index.hasOwnProperty(item.id)) { !gadget.state.seed_index.hasOwnProperty(item.id)) {
gadget.state.seed_index[item.id] = {}; gadget.state.seed_index[item.id] = {};
......
...@@ -242,7 +242,7 @@ ...@@ -242,7 +242,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>995.8389.48244.44663</string> </value> <value> <string>995.17036.58458.56166</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -260,7 +260,7 @@ ...@@ -260,7 +260,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1633361100.48</float> <float>1633425487.32</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