修复重构loader后ftp模块的bug
This commit is contained in:
@@ -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();
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user