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

savePath设置无效 #332

Open
lipc35 opened this issue Apr 2, 2021 · 16 comments
Open

savePath设置无效 #332

lipc35 opened this issue Apr 2, 2021 · 16 comments

Comments

@lipc35
Copy link

lipc35 commented Apr 2, 2021

接入版本:"com.github.ssseasonnn.RxDownload:rxdownload4:1.0.8"
通过Task设置了自定义的savePath
但成功后通过RxDownloadKt.file获取到的下载目录并不是我自定义的目录,必现

@zhui177
Copy link

zhui177 commented May 20, 2021

遇到同样问题了,请问你解决了吗?

@ssseasonnn
Copy link
Owner

你定义的路径必须是正确的路径,检查路径格式,打印路径发出来看看

@zhui177
Copy link

zhui177 commented May 22, 2021

你定义的路径必须是正确的路径,检查路径格式,打印路径发出来看看

代码 ```kotlin println(MobileVideoApplication.savePathDir) Task(url = url, savePath = MyApplication.savePathDir).url.download() .observeOn(AndroidSchedulers.mainThread()) .subscribeBy( onNext = { val percentage = 100 * it.downloadSize / it.totalSize println(percentage) circleProgressBar.progress = percentage.toInt() }, onComplete = { //install() println(MobileVideoApplication.savePathDir) circleProgressBar.visibility = View.GONE }, onError = { circleProgressBar.visibility = View.GONE it.printStackTrace() Toast.makeText(context, "更新失败,${it.message}", Toast.LENGTH_SHORT).show() } ) ```

前天跑的时候还能下载,不过修改下载地址后,发现下载的文件依然保存在Download里面。今天又跑了一下,下载都不行了。
I/System.out: /storage/emulated/0/Download/ //这是下载目录

这是报错 W/System.err: java.io.IOException: Not a directory W/System.err: at java.io.UnixFileSystem.createFileExclusively0(Native Method) at java.io.UnixFileSystem.createFileExclusively(UnixFileSystem.java:281) at java.io.File.createNewFile(File.java:1008) at zlc.season.rxdownload4.utils.FileUtilsKt.recreate(FileUtils.kt:20) at zlc.season.rxdownload4.utils.FileUtilsKt.recreate$default(FileUtils.kt:18) at zlc.season.rxdownload4.downloader.RangeDownloader.createFiles(RangeDownloader.kt:76) at zlc.season.rxdownload4.downloader.RangeDownloader.beforeDownload(RangeDownloader.kt:70) at zlc.season.rxdownload4.downloader.RangeDownloader.download(RangeDownloader.kt:35) at zlc.season.rxdownload4.task.TaskInfo$start$2.apply(TaskInfo.kt:55) at zlc.season.rxdownload4.task.TaskInfo$start$2.apply(TaskInfo.kt:13) at io.reactivex.internal.operators.flowable.FlowableFlatMap$MergeSubscriber.onNext(FlowableFlatMap.java:132) at io.reactivex.internal.operators.flowable.FlowableDoOnEach$DoOnEachSubscriber.onNext(FlowableDoOnEach.java:92) at io.reactivex.internal.operators.flowable.FlowableOnBackpressureLatest$BackpressureLatestSubscriber.drain(FlowableOnBackpressureLatest.java:129) at io.reactivex.internal.operators.flowable.FlowableOnBackpressureLatest$BackpressureLatestSubscriber.onNext(FlowableOnBackpressureLatest.java:68) W/System.err: at io.reactivex.internal.operators.flowable.FlowableFromObservable$SubscriberObserver.onNext(FlowableFromObservable.java:54) at io.reactivex.internal.operators.observable.ObservableSubscribeOn$SubscribeOnObserver.onNext(ObservableSubscribeOn.java:58) at retrofit2.adapter.rxjava2.CallExecuteObservable.subscribeActual(CallExecuteObservable.java:47) at io.reactivex.Observable.subscribe(Observable.java:12267) W/System.err: at io.reactivex.internal.operators.observable.ObservableSubscribeOn$SubscribeTask.run(ObservableSubscribeOn.java:96) at io.reactivex.Scheduler$DisposeTask.run(Scheduler.java:578) at io.reactivex.internal.schedulers.ScheduledRunnable.run(ScheduledRunnable.java:66) at io.reactivex.internal.schedulers.ScheduledRunnable.call(ScheduledRunnable.java:57) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:301) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641) at java.lang.Thread.run(Thread.java:764) I/Toast: Show toast from OpPackageName:com.example.mobilevideo, PackageName:com.example.mobilevideo W/System: A resource failed to call response.body().close().

@zhui177
Copy link

zhui177 commented May 22, 2021

你定义的路径必须是正确的路径,检查路径格式,打印路径发出来看看

不好意思,没注意代码格式

代码
                println(MobileVideoApplication.savePathDir)
                Task(url = url, savePath = MobileVideoApplication.savePathDir).url.download()
                    .observeOn(AndroidSchedulers.mainThread())
                    .subscribeBy(
                        onNext = {
                            val percentage = 100 * it.downloadSize / it.totalSize
                            println(percentage)
                            circleProgressBar.progress = percentage.toInt()
                        },
                        onComplete = {
                            //install()
                            println(MobileVideoApplication.savePathDir)
                            circleProgressBar.visibility = View.GONE
                        },
                        onError = {
                            circleProgressBar.visibility = View.GONE
                            it.printStackTrace()
                            Toast.makeText(context, "更新失败,${it.message}", Toast.LENGTH_SHORT).show()
                        }
                    )

@ssseasonnn
Copy link
Owner

I/System.out: /storage/emulated/0/Download/ 

你的path末尾多了一个反斜杠

@zhui177
Copy link

zhui177 commented May 25, 2021

I/System.out: /storage/emulated/0/Download/ 

你的path末尾多了一个反斜杠

又试了一下,现在不报错了,但是下载的文件保存在/data/data/packagename/files里面了,代码也没改啊,目录还是这个。

@zhui177
Copy link

zhui177 commented May 25, 2021

I/System.out: /storage/emulated/0/Download/ 

你的path末尾多了一个反斜杠

尝试了一下保存到/storage/emulated/0/Download,也不行,还是存到了/data/data/packagename/files里面。

@ssseasonnn
Copy link
Owner

清理下缓存,有下载记录的话会使用之前的目录

@zhui177
Copy link

zhui177 commented May 25, 2021

清理下缓存,有下载记录的话会使用之前的目录

试过了清理缓存和卸载重装,依然没有效果。刚才试了一下修改Demo中的下载目录,发现下载的文件保存在Download中,而不是指定的360目录。
image

@ssseasonnn
Copy link
Owner

我试试

@ssseasonnn
Copy link
Owner

没有复现你的问题,我这边试了是可以的,你用这个路径试试:

val path = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS).path

@zhui177
Copy link

zhui177 commented May 25, 2021

没有复现你的问题,我这边试了是可以的,你用这个路径试试:

val path = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS).path

我目前的情况是,在Demo中,是可以下载到Download文件夹中的,但是无法自定义下载目录;但在自己的项目中,一开始是可以保存到Download,但后面就不知道怎么回事了,要么报错,要么下载到了/data/data。如果有时间,能不能麻烦您试试运行一下这个Demo:https://wwa.lanzoui.com/i3t6wpgk7yh 。下载微信,保存的目录为/storage/emulated/0/360(也就是需要自定义目录)。

@ssseasonnn
Copy link
Owner

Task(url = url, savePath = MobileVideoApplication.savePathDir).url.download()

你这里写错了

应该是:

Task(url = url, savePath = MobileVideoApplication.savePathDir).download()

@zhui177
Copy link

zhui177 commented May 26, 2021

Task(url = url, savePath = MobileVideoApplication.savePathDir).url.download()

你这里写错了

应该是:

Task(url = url, savePath = MobileVideoApplication.savePathDir).download()

好吧,感谢大佬。看那个Issue是只注意到是换成task,直接在url.download()前面加了个task,没报错我就没注意到。然后自己项目里的使用还是下载到了/data/data,只能新建一个项目了。

@akingyin1987
Copy link

我设置的路径是 /data/data/packagename/files/DownLoad/APK 下面,也根本没用,还是保存在 /data/data/packagename/files 这个下面

@Teemo100
Copy link

Teemo100 commented Sep 20, 2022 via email

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

No branches or pull requests

5 participants