Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

finished torrents files get lock on electron-builder releases #1159

Closed
BenmasterTM opened this issue Jul 22, 2017 · 1 comment
Closed

finished torrents files get lock on electron-builder releases #1159

BenmasterTM opened this issue Jul 22, 2017 · 1 comment

Comments

@BenmasterTM
Copy link

@BenmasterTM BenmasterTM commented Jul 22, 2017

webtorrent 0.98.19
node 0.98.19
Windows 10 64 bits

I have a weird issue, dont know if is related to webtorrent or the electron-builder.
Im writing an application like webtorrent-desktop using webtorrent in electron, always is working fine, more or less, but when I export the application using the electron-builder, the application created to distribute the program, keep the downloaded torrents "lock", or the file stream open, and the file is not accesible, and the torrent.fileModTimes return invalid dates, because the files are writen when the client is closed and not when the torrent finish.

Here is a normal event when torrent finish:

    torrent.on('done', function(){
        
        console.log("torrent torrentDone")
        
        // save FileModtimes only if the torrent is finished & ready
        if (torrent.done == true && torrent.ready == true) {
            
                torrent.getFileModtimes(function (err, fileModtimes) {
                    console.log('set fileModTimes')
                    console.log(torrent)
                })           
        }
        
    })

This works perfect calling the application with "electron ." in the terminal, all torrent fileModTimes are saved correctly and when load the torrents using that the torrent dont check again all data.

But when I export the application with electron-builder, the torrent finished DONT WRITE the data to disk, before the client close, so the torrent.fileModTimes() function return not valid data because the files are writen after, when the client is closed, like the torrent stram is "locked" for some weird reason.

To solve that i need to do this:

    torrent.on('done', function(){
        
        console.log("torrent torrentDone")
        
        // save FileModtimes only if the torrent is finished & ready
        if (torrent.done == true && torrent.ready == true) {
            
            // for some reason when webtorrent run in ASAR file, the stream is locked until the client is closed, we need to free the stream manually
            torrent.store.close(function() {
                
                torrent.getFileModtimes(function (err, fileModtimes) {
                    console.log('set fileModTimes')
                    console.log(torrent)
                })
                
            })                   
            
        }
        
    })

The stream is closed, and the file data is saved (the files are updates in the HDD), and when I call the torrent.fileModTimes() I get valid dates.

But this is a dirty fix, because when I close the store, the file cant be read by webtorrent, and the upload speed drop to 0 kb/s because the file is closed, stopping all seed to other clients.

Someone have similar cases with the stream or something related using the files generated by the electron-builder ?

all help is wellcome.

@feross

This comment has been minimized.

Copy link
Member

@feross feross commented Apr 19, 2018

This issue has been open for a while so it's probably stale. I'm going to close it for now.

If you're still experiencing this issue, please leave a comment or open a new issue.

@feross feross closed this Apr 19, 2018
@lock lock bot locked as resolved and limited conversation to collaborators Jul 18, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.