1.物理删除文件时不删除远端文件。2.个人数据层级结构新增用户id隔离。

This commit is contained in:
chenxudong 2025-03-26 17:45:47 +08:00
parent 6a48585380
commit 5b2817d66e
2 changed files with 12 additions and 6 deletions

View File

@ -122,6 +122,11 @@ public class CommonService {
}
public String getEleDataPath(int dataOwnCode) {
if (DataOwnEnum.isUserCode(dataOwnCode)) {
return PATH_MAP.get(dataOwnCode) + File.separator + UserThreadLocal.getUserId() + File.separator;
}
return PATH_MAP.get(dataOwnCode);
}
@ -142,7 +147,7 @@ public class CommonService {
public String getFileSysPath(String dbPath, int dataOwnCode) {
ArrayList<String> paths = CollUtil.newArrayList(dbPath.split(MYSQL_FILE_PATH_SPLIT));
String path = getDbPath(paths);
return PATH_MAP.get(dataOwnCode) + File.separator + path;
return getEleDataPath(dataOwnCode) + File.separator + path;
}
public String getDbPath(String dbPath) {

View File

@ -128,6 +128,7 @@ public class FileRecycleServiceImpl implements FileRecycleService {
.eq(EdFileInfo::getFileId, fileId));
for (EdFileInfo edFileInfo : edFileInfos) {
String fileSysPath = commonService.getFileSysPath(edFileInfo.getFilePath(), edFileInfo.getDataOwn());
String fileDbPath = commonService.getDbPath(edFileInfo.getFilePath());
// 移动到tmp目录七天后删除
fileSystemService.moveFile(fileSysPath, elePropertyConfig.getEleTmpPath() + File.separator + new File(fileSysPath).getName());
// 更新MySQL数据库
@ -136,11 +137,11 @@ public class FileRecycleServiceImpl implements FileRecycleService {
.set(EdFileInfo::getEffectFlag, EffectFlagEnum.NOT_EFFECTIVE.code)
.set(EdFileInfo::getPermanentDeleted, true)
.set(EdFileInfo::getAllDeleted, true));
UserThreadLocal.setSuccessInfo(edFileInfo.getParentId(), edFileInfo.getId(), "删除文件 {} 成功文件id {}", edFileInfos.get(0).getFileName() + "." + edFileInfos.get(0).getFileType(), fileId);
BackupFileResLog resLog = backupHandler.deleteFile(edFileInfo.getId());
if (!Optional.ofNullable(resLog).map(BackupFileResLog::getBackupSuccess).orElse(false)) {
log.warn("删除备份文件异常");
}
UserThreadLocal.setSuccessInfo(edFileInfo.getParentId(), edFileInfo.getId(), "删除文件 {} 成功文件id {},文件路径 {}", edFileInfos.get(0).getFileName() + "." + edFileInfos.get(0).getFileType(), edFileInfo.getId(), fileDbPath);
// BackupFileResLog resLog = backupHandler.deleteFile(edFileInfo.getId());
// if (!Optional.ofNullable(resLog).map(BackupFileResLog::getBackupSuccess).orElse(false)) {
// log.warn("删除备份文件异常");
// }
return ElectromagneticResultUtil.success("删除文件成功");
}
return ElectromagneticResultUtil.success("删除文件成功");