mirror of
https://gitee.com/willfree/minbrowser.git
synced 2026-10-05 01:15:42 +08:00
修复BUG:取消传输后,本地会留存一个文件长度为零的空文件
This commit is contained in:
1 parent
eaa492b34f
commit
7c52ae9b92
1 file changed
+19
-4
+19
-4
@@ -9,10 +9,7 @@ import net.named_data.jndn.security.pib.Pib;
|
||||
import net.named_data.jndn.security.pib.PibImpl;
|
||||
import net.named_data.jndn.security.tpm.TpmBackEnd;
|
||||
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.io.RandomAccessFile;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.io.*;
|
||||
import java.net.URLDecoder;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Map;
|
||||
@@ -290,6 +287,8 @@ public class DownLoadClientBasedFacePool {
|
||||
public boolean finishWork(Integer transferFlag){
|
||||
// 关闭文件和facepool
|
||||
closeSelf();
|
||||
// 修复一些BUG
|
||||
correctFileError();
|
||||
// 根据关闭状态进行输出提示
|
||||
switch (transferFlag){
|
||||
case 0:
|
||||
@@ -319,6 +318,22 @@ public class DownLoadClientBasedFacePool {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 结束传输时,修复一些BUG:
|
||||
* 1.文件未开始传输,就生成了本地文件,取消传输后有一个字节长度为零的文件在本地。
|
||||
*/
|
||||
private void correctFileError(){
|
||||
try {
|
||||
String localName= FilePathUtil.getPureFileNameFromLinux(filename);
|
||||
File file=new File(URLDecoder.decode(localDir + localName,"UTF-8"));
|
||||
if(file.exists()&&(file.length()==0)){
|
||||
file.delete();
|
||||
}
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
System.out.println("Correct File Transfer Error: "+e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 下载一个数据片
|
||||
*
|
||||
|
||||
Reference in new issue
Block a user