fix bug https://github.com/AriaLyy/Aria/issues/508 fix bug https://github.com/AriaLyy/Aria/issues/503 修复m3u8创建索引不成功的问题
This commit is contained in:
@@ -16,13 +16,10 @@
|
||||
package com.arialyy.aria.core.download;
|
||||
|
||||
import android.text.TextUtils;
|
||||
import com.arialyy.aria.core.common.ErrorCode;
|
||||
import com.arialyy.aria.core.inf.ICheckEntityUtil;
|
||||
import com.arialyy.aria.core.inf.IOptionConstant;
|
||||
import com.arialyy.aria.core.inf.IRecordHandler;
|
||||
import com.arialyy.aria.core.inf.ITargetHandler;
|
||||
import com.arialyy.aria.core.wrapper.ITaskWrapper;
|
||||
import com.arialyy.aria.orm.DbEntity;
|
||||
import com.arialyy.aria.util.ALog;
|
||||
import com.arialyy.aria.util.CheckUtil;
|
||||
import com.arialyy.aria.util.CommonUtil;
|
||||
@@ -74,17 +71,13 @@ public class CheckDEntityUtil implements ICheckEntityUtil {
|
||||
mWrapper.getM3U8Params().setParams(IOptionConstant.cacheDir, cacheDir);
|
||||
M3U8Entity m3U8Entity = mEntity.getM3U8Entity();
|
||||
|
||||
Object temp = mWrapper.getM3U8Params().getParam(IOptionConstant.generateIndexFileTemp);
|
||||
boolean generateIndexFileTemp = temp != null && (boolean) temp;
|
||||
if (m3U8Entity == null) {
|
||||
m3U8Entity = new M3U8Entity();
|
||||
m3U8Entity.setFilePath(mEntity.getFilePath());
|
||||
m3U8Entity.setPeerIndex(0);
|
||||
m3U8Entity.setCacheDir(cacheDir);
|
||||
m3U8Entity.setGenerateIndexFile(generateIndexFileTemp);
|
||||
m3U8Entity.insert();
|
||||
} else {
|
||||
m3U8Entity.setGenerateIndexFile(generateIndexFileTemp);
|
||||
m3U8Entity.update();
|
||||
}
|
||||
if (mWrapper.getRequestType() == ITaskWrapper.M3U8_VOD) {
|
||||
@@ -140,15 +133,19 @@ public class CheckDEntityUtil implements ICheckEntityUtil {
|
||||
private boolean checkPathConflicts(String filePath) {
|
||||
//设置文件保存路径,如果新文件路径和旧文件路径不同,则修改路径
|
||||
if (!filePath.equals(mEntity.getFilePath())) {
|
||||
|
||||
//if (DbEntity.checkDataExist(DownloadEntity.class, "downloadPath=?", filePath)) {
|
||||
// if (!mWrapper.isForceDownload()) {
|
||||
// ALog.e(TAG, String.format("下载失败,保存路径【%s】已经被其它任务占用,请设置其它保存路径", filePath));
|
||||
// return false;
|
||||
// } else {
|
||||
// ALog.w(TAG, String.format("保存路径【%s】已经被其它任务占用,当前任务将覆盖该路径的文件", filePath));
|
||||
// RecordUtil.delTaskRecord(filePath, IRecordHandler.TYPE_DOWNLOAD);
|
||||
// }
|
||||
//}
|
||||
// 检查路径冲突
|
||||
if (DbEntity.checkDataExist(DownloadEntity.class, "downloadPath=?", filePath)) {
|
||||
if (!mWrapper.isForceDownload()) {
|
||||
ALog.e(TAG, String.format("下载失败,保存路径【%s】已经被其它任务占用,请设置其它保存路径", filePath));
|
||||
return false;
|
||||
} else {
|
||||
ALog.w(TAG, String.format("保存路径【%s】已经被其它任务占用,当前任务将覆盖该路径的文件", filePath));
|
||||
RecordUtil.delTaskRecord(filePath, IRecordHandler.TYPE_DOWNLOAD);
|
||||
}
|
||||
if (!CheckUtil.checkAndHandlePathConflicts(mWrapper.isForceDownload(), filePath)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
File newFile = new File(filePath);
|
||||
|
||||
@@ -18,7 +18,6 @@ package com.arialyy.aria.core.download.m3u8;
|
||||
import com.arialyy.aria.core.common.BaseOption;
|
||||
import com.arialyy.aria.core.processor.IBandWidthUrlConverter;
|
||||
import com.arialyy.aria.core.processor.ITsMergeHandler;
|
||||
import com.arialyy.aria.core.processor.IVodTsUrlConverter;
|
||||
import com.arialyy.aria.util.CheckUtil;
|
||||
import com.arialyy.aria.util.ComponentUtil;
|
||||
|
||||
@@ -27,8 +26,8 @@ import com.arialyy.aria.util.ComponentUtil;
|
||||
*/
|
||||
public class M3U8Option<OP extends M3U8Option> extends BaseOption {
|
||||
|
||||
private boolean generateIndexFileTemp = false;
|
||||
private boolean mergeFile = false;
|
||||
private boolean generateIndexFile = false;
|
||||
private boolean mergeFile = true;
|
||||
private int bandWidth;
|
||||
private ITsMergeHandler mergeHandler;
|
||||
private IBandWidthUrlConverter bandWidthUrlConverter;
|
||||
@@ -41,9 +40,10 @@ public class M3U8Option<OP extends M3U8Option> extends BaseOption {
|
||||
/**
|
||||
* 生成m3u8索引文件
|
||||
* 注意:创建索引文件,{@link #merge(boolean)}方法设置与否都不再合并文件
|
||||
* 如果是直播文件下载,创建索引文件的操作将导致只能同时下载一个切片!!
|
||||
*/
|
||||
public OP generateIndexFile() {
|
||||
this.generateIndexFileTemp = true;
|
||||
this.generateIndexFile = true;
|
||||
return (OP) this;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user