|
|
|
@ -18,6 +18,7 @@ package com.arialyy.aria.util; |
|
|
|
|
|
|
|
|
|
import android.text.TextUtils; |
|
|
|
|
import com.arialyy.aria.core.download.DownloadEntity; |
|
|
|
|
import com.arialyy.aria.core.download.DownloadGroupEntity; |
|
|
|
|
import com.arialyy.aria.core.inf.IRecordHandler; |
|
|
|
|
import com.arialyy.aria.core.upload.UploadEntity; |
|
|
|
|
import com.arialyy.aria.orm.DbEntity; |
|
|
|
@ -32,13 +33,13 @@ public class CheckUtil { |
|
|
|
|
private static final String TAG = "CheckUtil"; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 检查和处理路径冲突 |
|
|
|
|
* 检查和处理下载任务的路径冲突 |
|
|
|
|
* |
|
|
|
|
* @param isForceDownload true,如果路径冲突,将删除其它任务的记录的 |
|
|
|
|
* @param filePath 文件保存路径 |
|
|
|
|
* @return false 任务不再执行,true 任务继续执行 |
|
|
|
|
*/ |
|
|
|
|
public static boolean checkDownloadPathConflicts(boolean isForceDownload, String filePath) { |
|
|
|
|
public static boolean checkDPathConflicts(boolean isForceDownload, String filePath) { |
|
|
|
|
if (DbEntity.checkDataExist(DownloadEntity.class, "downloadPath=?", filePath)) { |
|
|
|
|
if (!isForceDownload) { |
|
|
|
|
ALog.e(TAG, String.format("下载失败,保存路径【%s】已经被其它任务占用,请设置其它保存路径", filePath)); |
|
|
|
@ -53,13 +54,13 @@ public class CheckUtil { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 检查和处理路径冲突 |
|
|
|
|
* 检查和处理上传任务的路径冲突 |
|
|
|
|
* |
|
|
|
|
* @param isForceUpload true,如果路径冲突,将删除其它任务的记录的 |
|
|
|
|
* @param filePath 文件保存路径 |
|
|
|
|
* @return false 任务不再执行,true 任务继续执行 |
|
|
|
|
*/ |
|
|
|
|
public static boolean checkUploadPathConflicts(boolean isForceUpload, String filePath) { |
|
|
|
|
public static boolean checkUPathConflicts(boolean isForceUpload, String filePath) { |
|
|
|
|
if (DbEntity.checkDataExist(UploadEntity.class, "filePath=?", filePath)) { |
|
|
|
|
if (!isForceUpload) { |
|
|
|
|
ALog.e(TAG, String.format("上传失败,文件路径【%s】已经被其它任务占用,请设置其它文件路径", filePath)); |
|
|
|
@ -73,6 +74,27 @@ public class CheckUtil { |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 检查和处理组合任务的路径冲突 |
|
|
|
|
* |
|
|
|
|
* @param isForceDownload true,如果路径冲突,将删除其它任务的记录的 |
|
|
|
|
* @param dirPath 文件保存路径 |
|
|
|
|
* @return false 任务不再执行,true 任务继续执行 |
|
|
|
|
*/ |
|
|
|
|
public static boolean checkDGPathConflicts(boolean isForceDownload, String dirPath) { |
|
|
|
|
if (DbEntity.checkDataExist(DownloadGroupEntity.class, "dirPath=?", dirPath)) { |
|
|
|
|
if (!isForceDownload) { |
|
|
|
|
ALog.e(TAG, String.format("下载失败,文件夹路径【%s】已经被其它任务占用,请设置其它文件路径", dirPath)); |
|
|
|
|
return false; |
|
|
|
|
} else { |
|
|
|
|
ALog.w(TAG, String.format("文件夹路径【%s】已经被其它任务占用,当前任务将覆盖该路径", dirPath)); |
|
|
|
|
RecordUtil.delGroupTaskRecordByPath(dirPath, false); |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 检查成员类是否是静态和public |
|
|
|
|
*/ |
|
|
|
|