解决文件copy的bug

This commit is contained in:
chenxudong 2025-04-16 11:41:23 +08:00
parent c983fda287
commit df763a94c9
1 changed files with 9 additions and 1 deletions

View File

@ -1120,7 +1120,6 @@ public class EdFileInfoServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileI
Assert.isTrue(FileRepeatEnum.contains(strategy), "解决重名文件参数错误"); Assert.isTrue(FileRepeatEnum.contains(strategy), "解决重名文件参数错误");
// 获取原文件mysql模型 // 获取原文件mysql模型
EdFileInfo srcFileInfo = this.baseMapper.selectById(id); EdFileInfo srcFileInfo = this.baseMapper.selectById(id);
String srcFileDbPath = srcFileInfo.getFilePath();
// 判断目标路径下是否有同名文件如果所有的同名文件1如果所有文件都已经被作废则该文件为新文件版本号从100开始2如果有没有被作废的文件则冲突处理方式按---1-跳过冲突文件 2-做版本更新 3-重命名文件名加"_1" // 判断目标路径下是否有同名文件如果所有的同名文件1如果所有文件都已经被作废则该文件为新文件版本号从100开始2如果有没有被作废的文件则冲突处理方式按---1-跳过冲突文件 2-做版本更新 3-重命名文件名加"_1"
long count = this.baseMapper.selectCount(Wrappers.lambdaQuery(EdFileInfo.class) long count = this.baseMapper.selectCount(Wrappers.lambdaQuery(EdFileInfo.class)
.eq(EdFileInfo::getParentId, targetFolderId) .eq(EdFileInfo::getParentId, targetFolderId)
@ -1145,6 +1144,9 @@ public class EdFileInfoServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileI
.setFilePath(destFolderInfo.getFilePath() + MYSQL_FILE_PATH_SPLIT + destFileInfo.getId()) .setFilePath(destFolderInfo.getFilePath() + MYSQL_FILE_PATH_SPLIT + destFileInfo.getId())
.setFileCode(newFileCode); .setFileCode(newFileCode);
this.baseMapper.insert(destFileInfo); this.baseMapper.insert(destFileInfo);
String srcPath = commonService.getFileSysPath(srcFileInfo.getId());
String destPath = commonService.getFileSysPath(destFileInfo.getId());
fileSystemService.copyFile(srcPath, destPath);
} else { } else {
destFileInfo = handCopyConflict(targetFolderId, strategy, srcFileInfo, destFolderInfo, dataOwnCode); destFileInfo = handCopyConflict(targetFolderId, strategy, srcFileInfo, destFolderInfo, dataOwnCode);
} }
@ -1252,6 +1254,9 @@ public class EdFileInfoServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileI
.eq(EdFileInfo::getFileName, srcFileInfo.getFileName()) .eq(EdFileInfo::getFileName, srcFileInfo.getFileName())
.eq(EdFileInfo::getFileType, srcFileInfo.getFileType()).set(EdFileInfo::getEffectFlag, EffectFlagEnum.NOT_EFFECTIVE.code)); .eq(EdFileInfo::getFileType, srcFileInfo.getFileType()).set(EdFileInfo::getEffectFlag, EffectFlagEnum.NOT_EFFECTIVE.code));
this.baseMapper.insert(destSaveFileInfo); this.baseMapper.insert(destSaveFileInfo);
String srcPath = commonService.getFileSysPath(srcFileInfo.getId());
String destPath = commonService.getFileSysPath(destSaveFileInfo.getId());
fileSystemService.copyFile(srcPath, destPath);
return destSaveFileInfo; return destSaveFileInfo;
} else { } else {
// 文件名加_1版本号从100开始 // 文件名加_1版本号从100开始
@ -1266,6 +1271,9 @@ public class EdFileInfoServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileI
.setFilePath(destFolderInfo.getFilePath() + MYSQL_FILE_PATH_SPLIT + newEdFileInfo.getId()); .setFilePath(destFolderInfo.getFilePath() + MYSQL_FILE_PATH_SPLIT + newEdFileInfo.getId());
resetFileInfoName(newEdFileInfo); resetFileInfoName(newEdFileInfo);
this.baseMapper.insert(newEdFileInfo); this.baseMapper.insert(newEdFileInfo);
String srcPath = commonService.getFileSysPath(srcFileInfo.getId());
String destPath = commonService.getFileSysPath(newEdFileInfo.getId());
fileSystemService.copyFile(srcPath, destPath);
return newEdFileInfo; return newEdFileInfo;
} }
} }