From c78fa1b66ab9decfbfa5a2539c920abd8b87b4fa Mon Sep 17 00:00:00 2001
From: laoyuyu <511455842@qq.com>
Date: Fri, 14 Aug 2020 22:40:17 +0800
Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=88=A0=E9=99=A4=E5=8A=A0?=
=?UTF-8?q?=E5=AF=86=E7=9A=84m3u8=E6=96=87=E4=BB=B6=E6=97=B6=EF=BC=8Ckey?=
=?UTF-8?q?=E6=B2=A1=E6=9C=89=E8=A2=AB=E5=88=A0=E9=99=A4=E7=9A=84=E9=97=AE?=
=?UTF-8?q?=E9=A2=98=20https://github.com/AriaLyy/Aria/issues/735#issuecom?=
=?UTF-8?q?ment-673958845?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
DEV_LOG.md | 1 +
.../http/upload/HttpUThreadTaskAdapter.java | 1 +
.../arialyy/aria/core/common/AbsEntity.java | 11 +++++++
.../arialyy/aria/util/DeleteM3u8Record.java | 29 ++++++++++++-------
.../download/m3u8/M3U8VodDLoadActivity.java | 2 +-
build.gradle | 2 +-
6 files changed, 34 insertions(+), 12 deletions(-)
diff --git a/DEV_LOG.md b/DEV_LOG.md
index 33b7ae68..1f6a928e 100644
--- a/DEV_LOG.md
+++ b/DEV_LOG.md
@@ -9,6 +9,7 @@
- 修复0kb的文件不可下载的问题 https://github.com/AriaLyy/Aria/issues/711
- 修复加密的m3u8下载,并且使用索引模式时,key的uri没有使用双引号的问题 https://github.com/AriaLyy/Aria/issues/731
- 修复删除m3u8索引文件后,下载完成回调无法触发的问题
+ - 修复删除加密的m3u8文件时,key没有被删除的问题 https://github.com/AriaLyy/Aria/issues/735#issuecomment-673958845
- 增加m3u8密钥下载地址转换器增加ts列表的url地址 https://github.com/AriaLyy/Aria/issues/718
- 增加现在http文件下载将使用HEAD请求获取文件大小,配置文件增加 。慎用,并不是所有服务器都支持head请求
- 增加允许不使用apt直接通过实现监听器来回调下载进度更新,该功能由[chenfei0928](https://github.com/chenfei0928)提交,感谢他的pr。如果注解不生效,只需要实现`DownloadListener`接口便可
diff --git a/HttpComponent/src/main/java/com/arialyy/aria/http/upload/HttpUThreadTaskAdapter.java b/HttpComponent/src/main/java/com/arialyy/aria/http/upload/HttpUThreadTaskAdapter.java
index 5c69904d..bb0605d9 100644
--- a/HttpComponent/src/main/java/com/arialyy/aria/http/upload/HttpUThreadTaskAdapter.java
+++ b/HttpComponent/src/main/java/com/arialyy/aria/http/upload/HttpUThreadTaskAdapter.java
@@ -219,6 +219,7 @@ final class HttpUThreadTaskAdapter extends BaseHttpThreadTaskAdapter {
String msg = "response msg: " + mHttpConn.getResponseMessage() + ",code: " + status;
ALog.e(TAG, msg);
fail(new AriaHTTPException(msg), false);
+ response.append(status);
}
writer.flush();
writer.close();
diff --git a/PublicComponent/src/main/java/com/arialyy/aria/core/common/AbsEntity.java b/PublicComponent/src/main/java/com/arialyy/aria/core/common/AbsEntity.java
index 4df5008b..653a8562 100644
--- a/PublicComponent/src/main/java/com/arialyy/aria/core/common/AbsEntity.java
+++ b/PublicComponent/src/main/java/com/arialyy/aria/core/common/AbsEntity.java
@@ -86,6 +86,17 @@ public abstract class AbsEntity extends DbEntity implements IEntity, Parcelable,
*/
private long stopTime = 0;
+ @Ignore
+ private int netCode = 200;
+
+ public int getNetCode() {
+ return netCode;
+ }
+
+ public void setNetCode(int netCode) {
+ this.netCode = netCode;
+ }
+
/**
* 获取剩余时间,单位:s
* 如果是m3u8任务,无法获取剩余时间;m2u8任务如果需要获取剩余时间,请设置文件长度{@link #setFileSize(long)}
diff --git a/PublicComponent/src/main/java/com/arialyy/aria/util/DeleteM3u8Record.java b/PublicComponent/src/main/java/com/arialyy/aria/util/DeleteM3u8Record.java
index 3b697b1f..919eeb70 100644
--- a/PublicComponent/src/main/java/com/arialyy/aria/util/DeleteM3u8Record.java
+++ b/PublicComponent/src/main/java/com/arialyy/aria/util/DeleteM3u8Record.java
@@ -80,26 +80,26 @@ public class DeleteM3u8Record implements IDeleteRecord {
TaskRecord record = DbDataHelper.getTaskRecord(filePath, entity.getTaskType());
if (record == null) {
ALog.e(TAG, "删除下载记录失败,记录为空,将删除实体记录,filePath:" + entity.getFilePath());
- deleteEntity(needRemoveEntity, filePath);
+ deleteEntity(entity.getTaskType(), needRemoveEntity, filePath);
return;
}
- // 删除下载的线程记录和任务记录
- DbEntity.deleteData(ThreadRecord.class, "taskKey=? AND threadType=?", filePath,
- String.valueOf(entity.getTaskType()));
- DbEntity.deleteData(TaskRecord.class, "filePath=? AND taskType=?", filePath,
- String.valueOf(entity.getTaskType()));
- DbEntity.deleteData(M3U8Entity.class, "filePath=?", filePath);
-
if (needRemoveFile || !entity.isComplete()) {
removeTsCache(new File(filePath), record.bandWidth);
FileUtil.deleteFile(filePath);
}
- deleteEntity(needRemoveEntity, filePath);
+ deleteEntity(entity.getTaskType(), needRemoveEntity, filePath);
}
- private void deleteEntity(boolean needRemoveEntity, String filePath){
+ private void deleteEntity(int taskType, boolean needRemoveEntity, String filePath){
+ // 删除下载的线程记录和任务记录
+ DbEntity.deleteData(ThreadRecord.class, "taskKey=? AND threadType=?", filePath,
+ String.valueOf(taskType));
+ DbEntity.deleteData(TaskRecord.class, "filePath=? AND taskType=?", filePath,
+ String.valueOf(taskType));
+ DbEntity.deleteData(M3U8Entity.class, "filePath=?", filePath);
+
if (needRemoveEntity) {
DbEntity.deleteData(DownloadEntity.class, "downloadPath=?", filePath);
}
@@ -110,6 +110,14 @@ public class DeleteM3u8Record implements IDeleteRecord {
*/
private static void removeTsCache(File targetFile, long bandWidth) {
+ // 删除key
+ M3U8Entity entity = DbEntity.findFirst(M3U8Entity.class, "filePath=?", targetFile.getPath());
+ if (entity != null && !TextUtils.isEmpty(entity.keyPath)){
+ File keyFile = new File(entity.keyPath);
+ FileUtil.deleteFile(keyFile);
+ }
+
+ // 删除ts
String cacheDir = null;
if (!targetFile.isDirectory()) {
cacheDir =
@@ -138,5 +146,6 @@ public class DeleteM3u8Record implements IDeleteRecord {
if (indexFile.exists()) {
indexFile.delete();
}
+
}
}
diff --git a/app/src/main/java/com/arialyy/simple/core/download/m3u8/M3U8VodDLoadActivity.java b/app/src/main/java/com/arialyy/simple/core/download/m3u8/M3U8VodDLoadActivity.java
index 25ac01d2..af3b15f2 100644
--- a/app/src/main/java/com/arialyy/simple/core/download/m3u8/M3U8VodDLoadActivity.java
+++ b/app/src/main/java/com/arialyy/simple/core/download/m3u8/M3U8VodDLoadActivity.java
@@ -120,7 +120,7 @@ public class M3U8VodDLoadActivity extends BaseActivity {
}
@Override public void cancel(View v, AbsEntity entity) {
- Aria.download(this).load(mTaskId).cancel();
+ Aria.download(this).load(mTaskId).cancel(true);
mTaskId = -1;
}
});
diff --git a/build.gradle b/build.gradle
index 758e7adf..b2584018 100644
--- a/build.gradle
+++ b/build.gradle
@@ -45,7 +45,7 @@ task clean(type: Delete) {
ext {
versionCode = 390
- versionName = '3.8.11-beta'
+ versionName = '3.8.11-beta-1'
userOrg = 'arialyy'
groupId = 'com.arialyy.aria'
publishVersion = versionName