vdonchev / xbt

Automatically exported from code.google.com/p/xbt
0 stars 0 forks source link

Problem in Cserver::write_db_torrents() with auto_register = 1 #6

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Hi,

I think I spotted a problem in void Cserver::write_db_torrents(). But first, my 
setup:
I'm running a recent XBTT with a MySQL Database and auto_register enabled. I 
also coded a web front-end to add torrents to the xbt_files table.

The problem is this: When a person uploads a torrent through the web interface 
and starts seeding it for the first time before the tracker has re-read the 
table, the tracker simply tries to insert the torrent again, without taking in 
consideration that it might exist already. The query to add it again will fail 
because of the duplicated info_hash key and also hinders the tracker to get a 
fid for future updates. The result is, that the database entry for that torrent 
won't updated at all unless the tracker is restarted.

Problematic line:
Csql_query(m_database, "insert into @files (info_hash, mtime, ctime) values (?, 
unix_timestamp(), unix_timestamp())")(i.first).execute();
I guess an "on duplicate key update"-clause or doing a "SELECT fid WHERE 
info_hash = info_hash" fist should help.

I hope, i didn't miss anything.

Greetings, Chris

Original issue reported on code.google.com by s...@kalania.de on 23 Jul 2011 at 10:26

GoogleCodeExporter commented 8 years ago
Hi Chris,

If you enable auto_register, you're not supposed to insert into xbt_files 
yourself.

Original comment by olafvdspek on 23 Jul 2011 at 12:12

GoogleCodeExporter commented 8 years ago
Hello,

that is bad ... since I need auto_register for "prerelease" distribution among 
seedboxes and the manual insertion for displaying a proper torrent-listing with 
additional torrent-information.

Can you consider an implementation that works in both cases?

Greetings, Chris

Original comment by s...@kalania.de on 23 Jul 2011 at 2:24

GoogleCodeExporter commented 8 years ago
Actually, never mind. I've come up with a plan to work around this.
(I'll move the additional torrent info stuff to a separate table and JOIN them 
using the info_hash, this is probably a more elegant solution anyway.)

As a help for future users of your tracker, you might want add what you posted 
in your first comment to your XBTT website.

Thanks for your time and keep up the good work!

Chris

Original comment by s...@kalania.de on 24 Jul 2011 at 2:50

GoogleCodeExporter commented 8 years ago

Original comment by olafvdspek on 6 Oct 2011 at 2:41