修复删除加密的m3u8文件时,key没有被删除的问题 https://github.com/AriaLyy/Aria/issues/735#issuecomment-673958845
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user