frostalf / libtorrent

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

set_piece_hases does not work with add_file (python) #595

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Hello, I'm trying to make a torrent for some files inside a folder and can't 
hash the files...

to add the files i'm using:
    for file in updateFiles:
        file = os.path.abspath(file)
        size = int(os.path.getsize(file))
        fs.add_file(file,size)

this works with folders but not with files... RuntimeError
    lt.set_piece_hashes(t, os.path.split(tPath)[0], lambda x: sys.stderr.write('.'))

so i tried to manually calculate the hash for the pieces i get an error that 
the object has no attribute 'hash_for_piece' :(
    for i in xrange(0, t.num_pieces()):
        hash = t.hash_for_piece(i)
        t.set_hash(i, hash)

also there is no way to use a filter for add_files
    lt.add_files(fs, tPath, filter())

------
is there anywhere where i can download an installer for the latest libtorrent 
build !? 16.15 !? i don't have bjam and not sure how to get it :|
------
python 2.7.6rc1 x86
libtorrent '0.16.10.0'
windows 8 pro x64

Original issue reported on code.google.com by Rappy...@gmail.com on 21 Mar 2014 at 10:18

GoogleCodeExporter commented 9 years ago
could you describe in a bit more detail what you're trying to do and what fails 
and how?
There is an example in the python binding directory called make_torrent.py 
which I believe works.
could you provide an example program that fails?

Original comment by arvid.no...@gmail.com on 23 Mar 2014 at 12:05

GoogleCodeExporter commented 9 years ago
I updated the make_torrent.py example to demonstrate that building the 
file_storage manually calling add_file() for each file does work. see the 
updated version (it may not sync with sourceforge for another hour or so):

   https://code.google.com/p/libtorrent/source/browse/branches/RC_0_16/bindings/python/make_torrent.py

I also exposed the missing overload of add_files()

Since that covers the title of this issue, I'll close it.

I'll open it if you can be more precise in the specific case that's failing for 
you.

Original comment by arvid.no...@gmail.com on 23 Mar 2014 at 12:53