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

想要通过taskId来clear或pause某个task的方法 #30

Closed
kerneltea opened this issue Apr 15, 2018 · 1 comment
Closed

想要通过taskId来clear或pause某个task的方法 #30

kerneltea opened this issue Apr 15, 2018 · 1 comment
Labels
Milestone

Comments

@kerneltea
Copy link

kerneltea commented Apr 15, 2018

在原来FileDownloader里有一个操作就是clear,之前clear的操作从源码上看应该是先pause然后在去清除对应文件 ,现在OkDownload中好像并没有看到相应的clear操作,不知道有没有比较好的方法?从1.0.0的版本上要想自己清除下载文件,我是需要这样么?
OkDownload.with().breakpointStore().remove(taskId)
但是上面这个方法好像并没有暂停的功能吧?

我要是暂停的话是不是还需要:
OkDownload.with().downloadDispatcher().cancel(task)
但是问题来了,如果下载后,我只想通过taskId来进行 暂停清除的功能,好像并不如之前FileDownloader里方便,如果只能通过task来暂停某个任务,在项目里还需要单独维护一个保存task的collection..
要么就是每次使用 StatusUtils.createFinder() 的方法再重新创建这个task,然后进行cancel,我看了下task的构造函数,还是有一些开销的

@Jacksgong Jacksgong added this to the 1.0.1 milestone Apr 15, 2018
@Jacksgong
Copy link
Collaborator

FileDownloader#clear在okdownload 1.0.1中相当于:

OkDownload.with().downloadDispatcher().cancel(id);
OkDownload.with().breakpointStore().remove(id);
new File(path).delete();

目前已经集成到1.0.1 snapshot,你可以通过该方式引入测试。

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

2 participants