JohnDoee / autotorrent

Matches torrents with files and gets them seeded
MIT License
269 stars 34 forks source link

ZeroDivisionError: division by zero if torrent contains empty files #10

Closed kaso17 closed 5 years ago

kaso17 commented 7 years ago

This happens if the torrent contains an empty files (found_size and missing_size = 0)

Traceback (most recent call last):
  File "autotorrent-env/bin/autotorrent", line 11, in <module>
    load_entry_point('autotorrent==1.6.1', 'console_scripts', 'autotorrent')()
  File "/var/lib/deluge/autotorrent-env/local/lib/python2.7/site-packages/autotorrent/cmd.py", line 214, in commandline_handler
    result = at.handle_torrentfile(os.path.join(current_path, torrent), dry_run)
  File "/var/lib/deluge/autotorrent-env/local/lib/python2.7/site-packages/autotorrent/at.py", line 430, in handle_torrentfile
    missing_percent = (missing_size / (found_size + missing_size)) * 100
ZeroDivisionError: division by zero
JohnDoee commented 7 years ago

I was a bit confused by this because if missing size and found size is zero, then the torrent contains no actual data to be downloaded. Is this correct ?

If yes, then I'll make it skip data-less torrents as it can't actually do much about them anyways.

kaso17 commented 7 years ago

Yes, you're correct. The torrent file was useless.

JohnDoee commented 5 years ago

I fixed this, thanks for reporting it. I forgot all about it again!