libtorrent-python problems, "no such file or directory" when there clearly is

491 views Asked by At

First of all, here's the code

#!/usr/bin/env python3.4
import libtorrent as lt
import os
fs = lt.file_storage()
lt.add_files(fs, "/var/mirror/packages/") # There are two files in this directory
t = lt.create_torrent(fs, flags = 1&8&16) # 1 = Optimization, 8 = Symbolic links, 16 = calculate file hashes.
t.add_tracker("udp://tracker.[private].com:80")
print(os.path.isdir("/var/mirror/packages/"))
lt.set_piece_hashes(t,"/var/mirror/packages/")

print(t.generate())

And here's what happens when I run it

True
Traceback (most recent call last):
  File "./test.py", line 9, in <module>
    lt.set_piece_hashes(t,"/var/mirror/packages/")
RuntimeError: No such file or directory

This is the page I got this from

I have browsed around the bindings, but I can't find the set_piece_hashes sources. It returns the same error code when I change the path to "." or "/" (keeping the add_files path the same)

Anyone know what I'm doing wrong? I can't find any sort of documentation other than the site I linked above

1

There are 1 answers

0
Niles On BEST ANSWER

Turns out set_piece_hashes wants the parent directory of the directory you created the filestore with. After I fixed that, I now get another error, which is a known bug in libtorrent here