trying to cleanup replace tracker code
This commit is contained in:
parent
2aaf9277c8
commit
b1d14357a1
|
@ -1157,8 +1157,7 @@ static PyObject *torrent_create_torrent(PyObject *self, PyObject *args)
|
||||||
t.set_piece_size(piece_size);
|
t.set_piece_size(piece_size);
|
||||||
|
|
||||||
file_pool fp;
|
file_pool fp;
|
||||||
boost::scoped_ptr<storage_interface> st(
|
boost::scoped_ptr<storage_interface> st(default_storage_constructor(t, full_path.branch_path(), fp));
|
||||||
default_storage_constructor(t, full_path.branch_path(), fp));
|
|
||||||
|
|
||||||
std::string stdTrackers(trackers);
|
std::string stdTrackers(trackers);
|
||||||
unsigned long index = 0, next = stdTrackers.find("\n");
|
unsigned long index = 0, next = stdTrackers.find("\n");
|
||||||
|
@ -1377,13 +1376,26 @@ static PyObject *torrent_replace_trackers(PyObject *self, PyObject *args)
|
||||||
|
|
||||||
std::string line;
|
std::string line;
|
||||||
|
|
||||||
int i = 0;
|
int cur_tier;
|
||||||
|
|
||||||
istringstream in(tracker);
|
for (int i = 0; i < trackerlist.size(); i++)
|
||||||
while(getline(in, line)){
|
{
|
||||||
trackerlist.push_back(line);
|
if (trackerlist[i].url == tracker)
|
||||||
++i;
|
{
|
||||||
|
cur_tier = trackerlist[i].tier;
|
||||||
|
announce_entry a(tracker);
|
||||||
|
a.tier = 0;
|
||||||
|
trackerlist.erase(trackerlist.begin() + i);
|
||||||
|
trackerlist.insert(trackerlist.begin(), a);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
for (int i = 1; i < trackerlist.size(); i++)
|
||||||
|
{
|
||||||
|
if (trackerlist[i].tier < cur_tier)
|
||||||
|
trackerlist[i].tier++;
|
||||||
|
}
|
||||||
|
cur_tier = 0;
|
||||||
h.replace_trackers(trackerlist);
|
h.replace_trackers(trackerlist);
|
||||||
h.force_reannounce();
|
h.force_reannounce();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue