修复重构loader后ftp模块的bug

This commit is contained in:
laoyuyu
2020-01-04 20:06:25 +08:00
parent c39bfbdd88
commit e14928e260
28 changed files with 141 additions and 85 deletions

View File

@@ -190,6 +190,27 @@ public class FileUtil {
return false;
}
/**
* 删除文件夹
*/
public static boolean deleteDir(File dirFile) {
// 如果dir对应的文件不存在则退出
if (!dirFile.exists()) {
return false;
}
if (dirFile.isFile()) {
return dirFile.delete();
} else {
for (File file : dirFile.listFiles()) {
deleteDir(file);
}
}
return dirFile.delete();
}
/**
* 将对象写入文件
*
@@ -275,9 +296,14 @@ public class FileUtil {
FileOutputStream fos = null;
FileChannel foc = null;
try {
if (!file.exists()) {
file.createNewFile();
if (file.exists() && file.isDirectory()) {
ALog.w(TAG, String.format("路径【%s】是文件夹将删除该文件夹", targetPath));
FileUtil.deleteDir(file);
}
if (!file.exists()) {
FileUtil.createFile(file);
}
fos = new FileOutputStream(targetPath);
foc = fos.getChannel();
List<FileInputStream> streams = new LinkedList<>();
@@ -383,8 +409,8 @@ public class FileUtil {
*/
public static boolean checkMemorySpace(String path, long fileSize) {
File temp = new File(path);
if (!temp.exists()){
if (!temp.getParentFile().exists()){
if (!temp.exists()) {
if (!temp.getParentFile().exists()) {
FileUtil.createDir(temp.getParentFile().getPath());
}
path = temp.getParentFile().getPath();

View File

@@ -142,7 +142,7 @@ public class RecordUtil {
int type;
if (entity instanceof DownloadEntity) {
type = IRecordHandler.TYPE_DOWNLOAD;
filePath = ((DownloadEntity) entity).getDownloadPath();
filePath = entity.getFilePath();
} else if (entity instanceof UploadEntity) {
type = IRecordHandler.TYPE_UPLOAD;
filePath = entity.getFilePath();