MikaTake / xbt

xbt
0 stars 0 forks source link

Reload info_hash #21

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
How can I get xbt reread info_hesh torrent?
First, you need to clear the old data and then write the new

This procedure should be triggered if the flags=2

tried to make available to the analogy, but I can not understand where the error

File: server.cpp

void Cserver::read_db_torrents_sql()
{
<------>try
<------>{
<------><------>if (!m_config.m_auto_register)
<------><------>{
<------><------><------>Csql_result result = Csql_query(m_database, "select 
info_hash, @fid, flags from @files where flags >= 1").execute();
<------><------><------>while (Csql_row row = result.fetch_row())
<------><------><------>{
<------><------><------><------>t_torrents::iterator i = 
m_torrents.find(row[0].s());
<------><------><------><------>if (row[2].i() == 1)
<------><------><------><------>{
<------><------><------><------><------>if (i != m_torrents.end())
<------><------><------><------><------>{
<------><------><------><------><------><------>BOOST_FOREACH(t_peers::reference
 j, i->second.peers)
<------><------><------><------><------><------>{
<------><------><------><------><------><------><------>if (t_user* user = 
find_user_by_uid(j.second.uid))
<------><------><------><------><------><------><------><------>(j.second.left 
? user->incompletes : user->completes)--;
<------><------><------><------><------><------>}
<------><------><------><------><------><------>m_torrents.erase(i);
<------><------><------><------><------>}
<------><------><------><------><------>Csql_query(m_database, "delete from 
@files where @fid = ?")(row[1].i()).execute();
<------><------><------><------>}

<------><------><------><------>else if (row[2].i() == 2)
<------><------><------><------>{
<------><------><------><------><------>if (i != m_torrents.end())
<------><------><------><------><------>{
<------><------><------><------><------><------>BOOST_FOREACH(t_peers::reference
 j, i->second.peers)
<------><------><------><------><------><------>{
<------><------><------><------><------><------><------>if (t_user* user = 
find_user_by_uid(j.second.uid))
<------><------><------><------><------><------><------><------>(j.second.left 
? user->incompletes : user->completes)--;
<------><------><------><------><------><------>}
<------><------><------><------><------><------>m_torrents.erase(i);

<------><------><------><------><------><------>if (row[0].size() != 20 || 
torrent(row[0].s()))
<------><------><------><------><------><------><------>continue;
<------><------><------><------><------><------>i->second.t_torrent& file = 
m_torrents[row[0].s()];
<------><------><------><------><------><------>i->second.dirty = false;
<------><------><------><------><------><------>i->second.fid = row[1].i();

<------><------><------><------><------>}
<------><------><------><------><------>Csql_query(m_database, "update @files 
set flags = 0 where @fid = ?")(row[1].i()).execute();
<------><------><------><------>}
<------><------><------>}
<------><------>}

Original issue reported on code.google.com by M.Sergi...@gmail.com on 8 Apr 2012 at 10:08

GoogleCodeExporter commented 9 years ago
Tracker does not support rereading rows from torrents table.

Original comment by olafvdspek on 18 Apr 2012 at 9:17

GoogleCodeExporter commented 9 years ago
I know this, but it can also do this?
there seems to be simple, if flag = 2, then re-read info hash

Original comment by M.Sergi...@gmail.com on 19 Apr 2012 at 4:54

GoogleCodeExporter commented 9 years ago
What would be the use case?

Original comment by olafvdspek on 19 Apr 2012 at 8:14

GoogleCodeExporter commented 9 years ago
in some systems id file = id news 
on remove the record of this file can not be (flag = 1), as xbt remove this 
news from DB, but after loading the new file to the news of his id does not 
change, and change only the info hash
until restart process xbt have error - unregister torrent

Original comment by M.Sergi...@gmail.com on 19 Apr 2012 at 8:32

GoogleCodeExporter commented 9 years ago
So don't do that and ensure new torrents have new IDs.

Original comment by olafvdspek on 19 Apr 2012 at 8:34

GoogleCodeExporter commented 9 years ago
information about the torrent fits into the table of news, that is the table 
news contains fields tables files, two tables in one
For this reason, all the news is not removed, but simply replaced info about 
file, so for this want to upgrade info hash file in xbt

Original comment by M.Sergi...@gmail.com on 19 Apr 2012 at 8:45

GoogleCodeExporter commented 9 years ago
Don't do that and ensure new torrents have new IDs.

Original comment by olafvdspek on 23 Apr 2012 at 8:11

GoogleCodeExporter commented 9 years ago
the same problem if I change the privacy torrent, such as an open to a closed, 
it changes the info_hash and also need restart xbt_tracker

Original comment by M.Sergi...@gmail.com on 23 Apr 2012 at 8:17

GoogleCodeExporter commented 9 years ago
Same solution: new torrent ID

Original comment by olafvdspek on 23 Apr 2012 at 8:18

GoogleCodeExporter commented 9 years ago

Original comment by olafvdspek on 28 Apr 2012 at 2:44