frostwire / frostwire-jlibtorrent

A swig Java interface for libtorrent by the makers of FrostWire. Develop libtorrent based apps with the joy of coding in Java.
http://www.frostwire.com
MIT License
444 stars 137 forks source link

No file is created while downloading #251

Closed MCrissDev closed 3 years ago

MCrissDev commented 3 years ago

Hello,

For some torrents, seems that even if the progress changes, there is no file created:

public TorrentInputStream getVideoStream() throws FileNotFoundException { File file = getVideoFile(); TorrentInputStream inputStream = new TorrentInputStream(this, file); torrentStreamReferences.add(new WeakReference<>(inputStream)); return inputStream; } This function will throw a FileNotFoundException but onStreamProgress is reporting that it is still downloading (in some cases more than 30% total file download but no file is actually created).

gubatron commented 3 years ago

you might want to want to share the code in getVideoFile()

MCrissDev commented 3 years ago

Hello,

This is it.

public File getVideoFile() { Log.e(TAG, "getVideoFile(): torrentHandle save path = " + torrentHandle.savePath()); return new File(torrentHandle.savePath() + "/" + torrentHandle.torrentFile().files().filePath(selectedFileIndex)); }

Strange thing is that this issue is maybe 80% reproducible. The same code 20% of the time creates that file. When the files are no created, i can see that some .part files are created instead.

gubatron commented 3 years ago

have you checked that the pieces for that file were downloaded? perhaps you are trying to open a file in the torrent that's not there yet

On Sat, Jan 30, 2021, 12:02 AM MCrissDev notifications@github.com wrote:

Hello,

This is it.

public File getVideoFile() { Log.e(TAG, "getVideoFile(): torrentHandle save path = " + torrentHandle.savePath()); return new File(torrentHandle.savePath() + "/" + torrentHandle.torrentFile().files().filePath(selectedFileIndex)); }

Strange thing it is that this issue is maybe 80% reproducible. The same code in 20% of the times creates that file.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/frostwire/frostwire-jlibtorrent/issues/251#issuecomment-770169533, or unsubscribe https://github.com/notifications/unsubscribe-auth/AABIBCK7H4XA7MKEVPODFG3S4OVH5ANCNFSM4WZPKZQA .

MCrissDev commented 3 years ago

The torrent contains just 1 single file so I doubt that is the case :)

gubatron commented 3 years ago

sounds like you haven't really checked the pieces are there.

libtorrent will usually save those pieces elsewhere and then at the end they will be at the location you are trying to open the file.

You need to use the piece checker to make sure the torrent has finally downloaded and assembled into the target file.