|
|
|
@ -23,6 +23,7 @@ import com.arialyy.aria.core.inf.IOptionConstant; |
|
|
|
|
import com.arialyy.aria.orm.DbEntity; |
|
|
|
|
import com.arialyy.aria.util.ALog; |
|
|
|
|
import com.arialyy.aria.util.CheckUtil; |
|
|
|
|
import com.arialyy.aria.util.FileUtil; |
|
|
|
|
import com.arialyy.aria.util.RecordUtil; |
|
|
|
|
import java.io.File; |
|
|
|
|
import java.util.ArrayList; |
|
|
|
@ -62,33 +63,40 @@ public class CheckDGEntityUtil implements ICheckEntityUtil { |
|
|
|
|
* @return {@code true} 合法 |
|
|
|
|
*/ |
|
|
|
|
private boolean checkDirPath() { |
|
|
|
|
if (TextUtils.isEmpty(mWrapper.getDirPathTemp())) { |
|
|
|
|
String dirPath = mWrapper.getDirPathTemp(); |
|
|
|
|
|
|
|
|
|
if (TextUtils.isEmpty(dirPath)) { |
|
|
|
|
ALog.e(TAG, "文件夹路径不能为null"); |
|
|
|
|
return false; |
|
|
|
|
} else if (!mWrapper.getDirPathTemp().startsWith("/")) { |
|
|
|
|
ALog.e(TAG, String.format("文件夹路径【%s】错误", mWrapper.getDirPathTemp())); |
|
|
|
|
} |
|
|
|
|
if (!FileUtil.canWrite(dirPath)){ |
|
|
|
|
ALog.e(TAG, String.format("路径【%s】不可写", dirPath)); |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
if (!dirPath.startsWith("/")) { |
|
|
|
|
ALog.e(TAG, String.format("文件夹路径【%s】错误", dirPath)); |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
File file = new File(mWrapper.getDirPathTemp()); |
|
|
|
|
File file = new File(dirPath); |
|
|
|
|
if (file.isFile()) { |
|
|
|
|
ALog.e(TAG, String.format("路径【%s】是文件,请设置文件夹路径", mWrapper.getDirPathTemp())); |
|
|
|
|
ALog.e(TAG, String.format("路径【%s】是文件,请设置文件夹路径", dirPath)); |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 检查路径冲突
|
|
|
|
|
if (mWrapper.isNewTask() && !CheckUtil.checkDGPathConflicts(mWrapper.isIgnoreFilePathOccupy(), |
|
|
|
|
mWrapper.getDirPathTemp())) { |
|
|
|
|
dirPath)) { |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (TextUtils.isEmpty(mEntity.getDirPath()) || !mEntity.getDirPath() |
|
|
|
|
.equals(mWrapper.getDirPathTemp())) { |
|
|
|
|
.equals(dirPath)) { |
|
|
|
|
if (!file.exists()) { |
|
|
|
|
file.mkdirs(); |
|
|
|
|
} |
|
|
|
|
needModifyPath = true; |
|
|
|
|
mEntity.setDirPath(mWrapper.getDirPathTemp()); |
|
|
|
|
ALog.i(TAG, String.format("文件夹路径改变,将更新文件夹路径为:%s", mWrapper.getDirPathTemp())); |
|
|
|
|
mEntity.setDirPath(dirPath); |
|
|
|
|
ALog.i(TAG, String.format("文件夹路径改变,将更新文件夹路径为:%s", dirPath)); |
|
|
|
|
} |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|