Commit 2784739b authored by Alain Takoudjou's avatar Alain Takoudjou

erp5_web_mynij_search: remove seeded torrent is seed was disabled on index source

parent 7a20dbff
...@@ -376,6 +376,7 @@ ...@@ -376,6 +376,7 @@
.onLoop(function () { .onLoop(function () {
var gadget = this, var gadget = this,
container = document.getElementById('seedactivities'), container = document.getElementById('seedactivities'),
seed_element,
info, info,
element, element,
i, i,
...@@ -383,8 +384,14 @@ ...@@ -383,8 +384,14 @@
if (!container) if (!container)
return; return;
info = container.querySelector('h2.info') info = container.querySelector('h2.info')
seed_element = container.querySelector('.torrent-seed');
key_list = Object.keys(gadget.state.seed_index); key_list = Object.keys(gadget.state.seed_index);
if (!key_list.length) { if (!key_list.length) {
if (!info && seed_element) {
info = document.createElement('h2');
info.className = 'info';
seed_element.appendChild(info);
}
info.innerText = "There is no torrent peer seeding!"; info.innerText = "There is no torrent peer seeding!";
} }
for (i = 0; i < key_list.length; i += 1) { for (i = 0; i < key_list.length; i += 1) {
...@@ -514,11 +521,12 @@ ...@@ -514,11 +521,12 @@
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": ["seed"] "select_list": ["title", "seed"]
}) })
.push(function (result_list) { .push(function (result_list) {
var i, var i,
promise_list = []; promise_list = [],
torrent_id;
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];
...@@ -527,6 +535,17 @@ ...@@ -527,6 +535,17 @@
gadget.state.seed_index[item.id] = {}; gadget.state.seed_index[item.id] = {};
promise_list.push(gadget.seedIndex(item.id)); promise_list.push(gadget.seedIndex(item.id));
console.log("call seed to " + item.id); console.log("call seed to " + item.id);
} else if (gadget.state.seed_index.hasOwnProperty(item.id)) {
// remove torrent seed
torrent_id = gadget.state.seed_index[item.id].infoHash
gadget.state.seed_index[item.id].destroy(function () {
var element = torrentHtmlElement(torrent_id);
console.log("Torrent of '" + item.value.title +
"' destroyed...");
if (element)
element.remove();
});
delete gadget.state.seed_index[item.id];
} }
} }
return RSVP.all(promise_list); return RSVP.all(promise_list);
......
...@@ -242,7 +242,7 @@ ...@@ -242,7 +242,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>989.27539.50696.19524</string> </value> <value> <string>989.30643.58517.13209</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>1610982586.19</float> <float>1611167690.79</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