|
@@ -295,13 +295,24 @@ public class LargeFileEndpoint {
|
|
|
QueryWrapper<LargeFile> wrapper = new QueryWrapper<LargeFile>()
|
|
|
.eq("file_key", param.getIdentifier()).eq("is_deleted",0).eq("shard_index",param.getChunkNumber()).orderByDesc("shard_index");
|
|
|
LargeFile list = iLargeFileService.getOne(wrapper);
|
|
|
- if(list != null ){
|
|
|
- result.setSuccess(true);
|
|
|
- result.setMsg("该分片已上传!");
|
|
|
- result.setData(list.getShardIndex());
|
|
|
- result.setCode(200);
|
|
|
- return result;
|
|
|
+ int state =0;
|
|
|
+
|
|
|
+ if(list != null){
|
|
|
+ if(StringUtils.isNotEmpty(list.getPath())){
|
|
|
+ File chfile = new File(list.getPath());
|
|
|
+ if(chfile.exists()){
|
|
|
+ result.setSuccess(true);
|
|
|
+ result.setMsg("该分片已上传!");
|
|
|
+ result.setData(list.getShardIndex());
|
|
|
+ result.setCode(200);
|
|
|
+ return result;
|
|
|
+ }else{
|
|
|
+ iLargeFileService.remove(wrapper);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
// 文件名称
|
|
|
String fileName = getFileName(param);
|
|
|
// 临时文件名称
|
|
@@ -309,6 +320,7 @@ public class LargeFileEndpoint {
|
|
|
// 获取文件路径
|
|
|
/**Windows文件路径要加在哪个盘**/
|
|
|
String filePath =ParamCache.getValue(CommonConstant.SYS_LOCAL_URL)+"largeFile/";
|
|
|
+ //String filePath ="/Users/hongchuangyanfa/Desktop/largeFile/";
|
|
|
|
|
|
File tempFile = buildUploadFile(tempFileName);
|
|
|
|
|
@@ -336,6 +348,8 @@ public class LargeFileEndpoint {
|
|
|
largeFile.setSuffix(param.getObjectType());
|
|
|
iLargeFileService.save(largeFile);
|
|
|
|
|
|
+ if(param.getTotalChunks()== param.getChunkNumber()){
|
|
|
+ Thread.sleep(400);
|
|
|
//第八步 检查文件是否全部完成上传
|
|
|
lock.lock();
|
|
|
try {
|
|
@@ -404,6 +418,7 @@ public class LargeFileEndpoint {
|
|
|
} finally {
|
|
|
lock.unlock();
|
|
|
}
|
|
|
+ }
|
|
|
result.setCode(200);
|
|
|
result.setSuccess(true);
|
|
|
result.setMsg("上传成功!");
|
|
@@ -451,6 +466,7 @@ public class LargeFileEndpoint {
|
|
|
*/
|
|
|
private String buildUploadDir() {
|
|
|
String fullDir =ParamCache.getValue(CommonConstant.SYS_LOCAL_URL)+"largeFile/";
|
|
|
+ //String fullDir ="/Users/hongchuangyanfa/Desktop/largeFile/";
|
|
|
File dir = new File(fullDir);
|
|
|
if (!dir.exists()) {
|
|
|
dir.mkdirs();
|