Skip to content

Commit 89ced99

Browse files
committed
Preventing name-collision to mess up with the tool
For performances and mirrorbrain-load issues, we were reconciling the existing torrents and books using their filename. This adds a btih check for those that matches the name. This saves the request spam for all books while ensuring we still eventually match on btih.
1 parent 4a793f4 commit 89ced99

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

bittorrent-seeder/src/kiwixseeder/runner.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,12 @@ def remove_outdated_torrents(self):
147147
btihs = [
148148
btih
149149
for btih, fname in self.manager.btihs.items()
150-
if fname == book.filename
150+
# having condition on name first is important and it allows
151+
# us to only compare on btih if name matches.
152+
# we cant direclty compare on btih as it would require getting the
153+
# btih of all books otherwise which is resource intensive as it
154+
# requires an HTTP GET for each
155+
if fname == book.filename and book.btih == btih
151156
]
152157
if btihs:
153158
book.btih = btihs[0]

0 commit comments

Comments
 (0)