Open dechamps opened 2 months ago
Yes, unfortunately, torf needs to get a lot of its smartness ripped out and replaced with a healthy chunk of dumbness. But that's essentially a rewrite.
This particular issue might get fixed like this:
@property
def path(self):
if self._path and os.path.exists(self._path):
return self._path
But I'm not sure if that creates any other issues. I don't think it should, but maybe torf disagrees.
I find the following… odd (torf 4.2.7):
Especially since the following works:
As it turns out there are a number of problems here:
validate()
does not mention anything about checking files.validate()
to do file I/O - that's surprising and inefficient.verify()
would make much more sense (e.g. "verify lite" which only checks file existence but not the contents)Torrent
objects will check files invalidate()
, others won't. That's very confusing.Torrent.infohash
get accessor callsvalidate()
, which means simply writing the expressiontorrent.infohash
is enough to trigger file I/O and fail on missing files, which is ridiculous.A workaround is to set
torrent._path = None
immediately aftertorrent.generate()
to make the object forget about the files and make it behave like a torrent read from a torrent file. (Note thattorrent.path = None
won't quite work because it clearspieces
internally which then makesvalidate()
fail. I suspect that's another bug.)