修复删除加密的m3u8文件时,key没有被删除的问题 https://github.com/AriaLyy/Aria/issues/735#issuecomment-673958845

pull/789/head
laoyuyu 4 years ago
parent 428fbab9d2
commit c78fa1b66a
  1. 1
      DEV_LOG.md
  2. 1
      HttpComponent/src/main/java/com/arialyy/aria/http/upload/HttpUThreadTaskAdapter.java
  3. 11
      PublicComponent/src/main/java/com/arialyy/aria/core/common/AbsEntity.java
  4. 29
      PublicComponent/src/main/java/com/arialyy/aria/util/DeleteM3u8Record.java
  5. 2
      app/src/main/java/com/arialyy/simple/core/download/m3u8/M3U8VodDLoadActivity.java
  6. 2
      build.gradle

@ -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请求获取文件大小,配置文件增加 <useHeadRequest value="true"/>。慎用,并不是所有服务器都支持head请求
- 增加允许不使用apt直接通过实现监听器来回调下载进度更新,该功能由[chenfei0928](https://github.com/chenfei0928)提交,感谢他的pr。如果注解不生效,只需要实现`DownloadListener`接口便可

@ -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();

@ -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)}

@ -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();
}
}
}

@ -120,7 +120,7 @@ public class M3U8VodDLoadActivity extends BaseActivity<ActivityM3u8VodBinding> {
}
@Override public void cancel(View v, AbsEntity entity) {
Aria.download(this).load(mTaskId).cancel();
Aria.download(this).load(mTaskId).cancel(true);
mTaskId = -1;
}
});

@ -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

Loading…
Cancel
Save