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

多次下载同名文件。下载一半就显示下载成功 #493

Closed
yaoZhao0323 opened this issue Oct 30, 2019 · 24 comments

Comments

@yaoZhao0323
Copy link

@yaoZhao0323 yaoZhao0323 commented Oct 30, 2019

Aria版本

3.7.2

什么问题

下载成功一遍文件,在手机设置里清空了一遍应用数据。重新下载一遍文件,相同下载地址,相同文件存储地址。有一个线程会直接显示成功。

如何复现此问题

下载一个文件,去设置界面,清空应用数据。
long taskId = Aria.download(this)
.load(url) //读取下载地址
.setFilePath(file.getPath(),true) //设置文件保存的完整路径
.create(); //启动下载
使用这个方法强制下载。

控制台日志

image
image
线程2几十ms就成功,线程0、线程1都是正常的16s成功。

@AriaLyy

This comment has been minimized.

Copy link
Owner

@AriaLyy AriaLyy commented Oct 30, 2019

检查下下载文件的md5 码是否正确

@yaoZhao0323

This comment has been minimized.

Copy link
Author

@yaoZhao0323 yaoZhao0323 commented Oct 30, 2019

测试了一下,服务器那边没有设置md5码。需要设置为随机字符串的MD5码吗?

@AriaLyy

This comment has been minimized.

Copy link
Owner

@AriaLyy AriaLyy commented Oct 31, 2019

md5是需要你自己验证的

@yaoZhao0323

This comment has been minimized.

Copy link
Author

@yaoZhao0323 yaoZhao0323 commented Oct 31, 2019

校验下载文件的MD5值不对,是需要重新执行一遍下载么。

@AriaLyy

This comment has been minimized.

Copy link
Owner

@AriaLyy AriaLyy commented Oct 31, 2019

是的,文件不对删除任务重新开始

@yaoZhao0323

This comment has been minimized.

Copy link
Author

@yaoZhao0323 yaoZhao0323 commented Oct 31, 2019

有别的办法么,下完之后再验证然后回滚,显得有些奇怪。我试过用Aria.download(this).removeAllTask(true)清空下载记录也不行。是什么地方的缓存导致这个问题的么?

@AriaLyy

This comment has been minimized.

Copy link
Owner

@AriaLyy AriaLyy commented Oct 31, 2019

url 和 你的配置提供我下,我这测试是正常的。。

@yaoZhao0323

This comment has been minimized.

Copy link
Author

@yaoZhao0323 yaoZhao0323 commented Oct 31, 2019

http://image.totwoo.com/totwoo-TOTWOO-v3.5.6.apk 下载地址是这个。配置方面具体需要哪些

@AriaLyy

This comment has been minimized.

Copy link
Owner

@AriaLyy AriaLyy commented Oct 31, 2019

@yaoZhao0323

This comment has been minimized.

Copy link
Author

@yaoZhao0323 yaoZhao0323 commented Oct 31, 2019

我没有配置过这些参数,应该走的都是默认值吧

@AriaLyy

This comment has been minimized.

Copy link
Owner

@AriaLyy AriaLyy commented Oct 31, 2019

我这测试了好几次都正常。。。。

@yaoZhao0323

This comment has been minimized.

Copy link
Author

@yaoZhao0323 yaoZhao0323 commented Nov 1, 2019

好啊,我再想想别的办法吧。谢谢。库写的很棒,加油!

@AriaLyy

This comment has been minimized.

Copy link
Owner

@AriaLyy AriaLyy commented Nov 1, 2019

谢谢 ☺️

@yaoZhao0323

This comment has been minimized.

Copy link
Author

@yaoZhao0323 yaoZhao0323 commented Nov 1, 2019

我发现了一点别的情况。我重装App,把目标路径的文件删除也有可能出现这样的问题(有这样的log:HttpFileInfoThread: 长度不一致,任务为新任务。如图)。我换了2个手机都存在这种情况。
image

@AriaLyy

This comment has been minimized.

Copy link
Owner

@AriaLyy AriaLyy commented Nov 1, 2019

这个不影响,只是用来判断是否有同名文件的。

@yaoZhao0323

This comment has been minimized.

Copy link
Author

@yaoZhao0323 yaoZhao0323 commented Nov 1, 2019

我改成1个线程了,也是不到50ms就显示成功了。实际文件是0b,但是task返回的长度是正确的

@AriaLyy

This comment has been minimized.

Copy link
Owner

@AriaLyy AriaLyy commented Nov 1, 2019

步骤是哪些?

@yaoZhao0323

This comment has been minimized.

Copy link
Author

@yaoZhao0323 yaoZhao0323 commented Nov 1, 2019

下载成功一遍、删除App、删除本地下载的文件、重新下载一边文件。
Aria.get(this).getDownloadConfig().setThreadNum(1);
我用的是单线程
long taskId = Aria.download(this)
.load(url) //读取下载地址
.setFilePath(file.getPath(),true) //设置文件保存的完整路径
.create(); //启动下载
下载还是这种方式。
PS:我试过不删除本地包是没有问题的。
我用华为手机和vivo手机都试过,都会出现。应该跟手机无关

@AriaLyy

This comment has been minimized.

Copy link
Owner

@AriaLyy AriaLyy commented Nov 1, 2019

删除下载成的包就出问题?还是删除app?

@yaoZhao0323

This comment has been minimized.

Copy link
Author

@yaoZhao0323 yaoZhao0323 commented Nov 1, 2019

同时删除下载成功的包和App。然后重新安装App

@AriaLyy

This comment has been minimized.

Copy link
Owner

@AriaLyy AriaLyy commented Nov 1, 2019

将 useBlock 改为 true看看

@yaoZhao0323

This comment has been minimized.

Copy link
Author

@yaoZhao0323 yaoZhao0323 commented Nov 1, 2019

image
还是不行。。。

@yaoZhao0323

This comment has been minimized.

Copy link
Author

@yaoZhao0323 yaoZhao0323 commented Nov 1, 2019

试了你的demo,确实不会复现。然后我按照你的demo加了option。
HttpOption option = new HttpOption();
option.addHeader("1", "@")
.useServerFileName(true)
.setFileLenAdapter(new FileLenAdapter());
image

AriaLyy added a commit that referenced this issue Nov 2, 2019
@AriaLyy

This comment has been minimized.

Copy link
Owner

@AriaLyy AriaLyy commented Nov 2, 2019

使用3.7.4看看

@AriaLyy AriaLyy closed this Nov 10, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.