Discussion:
[libtorrent] hash check
Ömer Faruk Özer
2015-01-30 14:40:40 UTC
Permalink
Hi,

I need to take specific actions when a file is changed after it has
downloaded.

I can't find how to detect this situation.

hash_failed_alert is never called. I assume this alert is sent only when a
downloaded piece fails hash check.

force_recheck does not generate this alert too. It would be great if a
specific alert is generated when file checking detects something is wrong.

Thanks in advance
sledgehammer999
2015-02-01 10:03:02 UTC
Permalink
You can detect this when loading a torrent at startup and giving a
fastresume. If anything is wrong with the files you'll get
fastresume_rejected_alert
Then check its error_code for different things. eg if a file is missing
you'll probably have an error_code of errors::mismatching_file_size
I don't know if there is something you can during runtime though...
Post by Ömer Faruk Özer
Hi,
I need to take specific actions when a file is changed after it has
downloaded.
I can't find how to detect this situation.
hash_failed_alert is never called. I assume this alert is sent only when a
downloaded piece fails hash check.
force_recheck does not generate this alert too. It would be great if a
specific alert is generated when file checking detects something is wrong.
Thanks in advance
------------------------------------------------------------------------------
Dive into the World of Parallel Programming. The Go Parallel Website,
sponsored by Intel and developed in partnership with Slashdot Media, is
your
hub for all things parallel software development, from weekly thought
leadership blogs to news, videos, case studies, tutorials and more. Take a
look and join the conversation now. http://goparallel.sourceforge.net/
_______________________________________________
Libtorrent-discuss mailing list
https://lists.sourceforge.net/lists/listinfo/libtorrent-discuss
arvid
2015-02-01 14:39:42 UTC
Permalink
Post by Ömer Faruk Özer
Hi,
I need to take specific actions when a file is changed after it has
downloaded.
I can't find how to detect this situation.
hash_failed_alert is never called. I assume this alert is sent only when a
downloaded piece fails hash check.
force_recheck does not generate this alert too. It would be great if a
specific alert is generated when file checking detects something is wrong.
libtorrent does not monitor files for external changes. It assumes that
files are exclusively modified by libtorrent (except in between
sessions,
where the resume data records mtimes etc.).

Hash check failures only fire when data you _download_ is corrupt, not
when you upload corrupt data. If files are modified while libtorrent
seeds them, it will start sending corrupt data to other peers, most
likely resulting in you being banned from most peers on the swarm
eventually.

there is one exception when you have seed_mode enabled, in which case
the assumption is that you have all files completely, but the first
time a piece is sent, it's first checked. This check only happens
once though. It's a way to amortize the cost of checking files
on startup over a longer period of time.

If you need to know when files changes externally, you could
monitor them with some OS provided monitoring API (ideally once
they're seeding, because then libtorrent won't modify them anymore).
--
Arvid Norberg
Loading...