From a5fc5d0bcfacb42139b088f746beb7394c90a8c0 Mon Sep 17 00:00:00 2001 From: laoyuyu <511455842@qq.com> Date: Tue, 23 Jul 2019 20:52:30 +0800 Subject: [PATCH] fix bug https://github.com/AriaLyy/Aria/issues/429 --- .../main/java/com/arialyy/aria/core/AriaManager.java | 10 ++++------ .../core/download/downloader/HttpFileInfoThread.java | 9 +++++++-- README.md | 1 - build.gradle | 2 +- 4 files changed, 12 insertions(+), 10 deletions(-) diff --git a/Aria/src/main/java/com/arialyy/aria/core/AriaManager.java b/Aria/src/main/java/com/arialyy/aria/core/AriaManager.java index 21b80459..d99589ff 100644 --- a/Aria/src/main/java/com/arialyy/aria/core/AriaManager.java +++ b/Aria/src/main/java/com/arialyy/aria/core/AriaManager.java @@ -161,13 +161,11 @@ import org.xml.sax.SAXException; * 初始化数据库 */ private void initDb(Context context) { - // 这个地方错误了,获取数据库路径见:https://www.jianshu.com/p/815c9efc5449 String oldDbName = "AriaLyyDb"; - String oldDbPath = context.getDatabasePath(oldDbName).getPath(); - File db = new File(oldDbPath); - File dbConfig = new File(String.format("%s/%s", db.getParent(), "AriaLyyDb-journal")); - if (db.exists()) { - db.renameTo(new File(String.format("%s/%s", db.getParent(), "AndroidAria.db"))); + File oldDbFile = context.getDatabasePath(oldDbName); + if (oldDbFile != null && oldDbFile.exists()) { + File dbConfig = new File(String.format("%s/%s", oldDbFile.getParent(), "AriaLyyDb-journal")); + oldDbFile.renameTo(new File(String.format("%s/%s", oldDbFile.getParent(), "AndroidAria.db"))); // 如果数据库是在/data/data/{packagename}/databases/下面,journal文件因权限问题将无法删除和重命名 if (dbConfig.exists()) { dbConfig.delete(); diff --git a/Aria/src/main/java/com/arialyy/aria/core/download/downloader/HttpFileInfoThread.java b/Aria/src/main/java/com/arialyy/aria/core/download/downloader/HttpFileInfoThread.java index 78f7a229..2bee53b4 100644 --- a/Aria/src/main/java/com/arialyy/aria/core/download/downloader/HttpFileInfoThread.java +++ b/Aria/src/main/java/com/arialyy/aria/core/download/downloader/HttpFileInfoThread.java @@ -16,6 +16,7 @@ package com.arialyy.aria.core.download.downloader; import android.net.TrafficStats; +import android.net.Uri; import android.os.Process; import android.text.TextUtils; import com.arialyy.aria.core.AriaManager; @@ -284,13 +285,17 @@ public class HttpFileInfoThread implements Runnable { */ private void handleUrlReTurn(HttpURLConnection conn, String newUrl) throws IOException { ALog.d(TAG, "30x跳转,新url为【" + newUrl + "】"); - if (TextUtils.isEmpty(newUrl) || newUrl.equalsIgnoreCase("null") || !newUrl.startsWith( - "http")) { + if (TextUtils.isEmpty(newUrl) || newUrl.equalsIgnoreCase("null")) { if (onFileInfoCallback != null) { onFileInfoCallback.onFail(mEntity, new TaskException(TAG, "获取重定向链接失败"), false); } return; } + if (newUrl.startsWith("/")) { + Uri uri = Uri.parse(mEntity.getUrl()); + newUrl = uri.getHost() + newUrl; + } + if (!CheckUtil.checkUrlNotThrow(newUrl)) { failDownload(new TaskException(TAG, "下载失败,重定向url错误"), false); return; diff --git a/README.md b/README.md index a695aef5..99598aee 100644 --- a/README.md +++ b/README.md @@ -158,7 +158,6 @@ protected void onCreate(Bundle savedInstanceState) { ## 其他 有任何问题,可以在[issues](https://github.com/AriaLyy/Aria/issues)给我留言反馈。
在提交问题前,希望你已经查看过[wiki](https://aria.laoyuyu.me/aria_doc/)或搜索过[issues](https://github.com/AriaLyy/Aria/issues)。
- 交流群:524329160 *** diff --git a/build.gradle b/build.gradle index 1fac0216..05b0c05b 100644 --- a/build.gradle +++ b/build.gradle @@ -43,7 +43,7 @@ task clean(type: Delete) { ext { userOrg = 'arialyy' groupId = 'com.arialyy.aria' - publishVersion = '3.6.5' + publishVersion = '3.6.6_beta_1' // publishVersion = '1.0.4' //FTP插件 repoName='maven' desc = 'android 下载框架'