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

Stop a download #33

Closed
leeroybrun opened this issue Mar 10, 2015 · 5 comments
Closed

Stop a download #33

leeroybrun opened this issue Mar 10, 2015 · 5 comments
Labels

Comments

@leeroybrun
Copy link
Contributor

Hi,

Thanks for your module, it's very usefull and working great !

Is there an easy way to stop (cancel) a download ?

@tusharmath
Copy link
Owner

There is no easy way to do this as of now. The only way you can do it is as follows -

var mtd = require('mt-downloader');

var url = 'https://upload.wikimedia.org/wikipedia/commons/4/47/Gadget_the_pug_expressive_eyes.jpg';
var file = './Gadget_the_pug_expressive_eyes.jpg';

var downloader = new mtd(file, url, {
    onStart: function (data) {
        data.threads.each(function(i){
            i.destroy();
        });
    }
});

downloader.start();

I hope this helps. I would be glad to merge a pull request which would make it easier.

@leeroybrun
Copy link
Contributor Author

It seems quite easy, just what I needed.
Thanks !

@artemkloko
Copy link

Is it safe to just destroy the threads? I implemented your proposal and sometimes I get a corrupted mtd file, which cannot be resumed.

@gjtjsvxzrtx626n4
Copy link

I think you should send a destroy event to the thread

Sent from Mail.Ru app for iOS

Thursday 14 January 2016 18:24 +0300 from notifications@github.com notifications@github.com:

Is it safe to just destroy the threads? I implemented your proposal and sometimes I get a corrupted mtd file, which cannot be resumed.

Reply to this email directly or view it on GitHub .

@artemkloko
Copy link

Yes, that's what I do. But my question is if it is safe do to so? Because sometimes I get corrupted mtd file, which can not be resumed...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants