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 @@
.declareMethod('render', function (options) {
var state_dict = {
href: options.value || options.default,
alt: options.description || options.key
href: options.value || options.default || "",
alt: options.description || options.key || ""
};
return this.changeState(state_dict);
})
......@@ -25,6 +25,8 @@
while (gadget.element.firstChild) {
gadget.element.removeChild(gadget.element.lastChild);
}
if (!gadget.state.href)
return;
gadget.element.append(link);
})
......
......@@ -234,7 +234,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>995.16010.44333.13482</string> </value>
<value> <string>995.16964.34495.18124</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -252,7 +252,7 @@
</tuple>
<state>
<tuple>
<float>1633363899.54</float>
<float>1633421737.53</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -557,16 +557,34 @@
},
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 () {
var gadget = this;
function notify(msg, status) {
return gadget.notifySubmitted({
message: msg,
status: status || "error"
});
}
function seedTorrent() {
return gadget.jio_allDocs({
query: 'portal_type: "Mynij Search Collection"',
"select_list": ["title", "seed"]
"select_list": ["title", "seed", "status"]
})
.push(function (result_list) {
var i,
......@@ -575,6 +593,12 @@
console.log(result_list);
for (i = 0; i < result_list.data.rows.length; i += 1) {
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" &&
!gadget.state.seed_index.hasOwnProperty(item.id)) {
gadget.state.seed_index[item.id] = {};
......
......@@ -242,7 +242,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>995.8389.48244.44663</string> </value>
<value> <string>995.17036.58458.56166</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -260,7 +260,7 @@
</tuple>
<state>
<tuple>
<float>1633361100.48</float>
<float>1633425487.32</float>
<string>UTC</string>
</tuple>
</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