|
@@ -22,7 +22,7 @@ import java.util.stream.Collectors;
|
|
|
*/
|
|
*/
|
|
|
@Service
|
|
@Service
|
|
|
public class DiskFolderService {
|
|
public class DiskFolderService {
|
|
|
- private DiskFileService diskFileService;
|
|
|
|
|
|
|
+ private final DiskFileService diskFileService;
|
|
|
private final DiskFileMapper diskFileMapper;
|
|
private final DiskFileMapper diskFileMapper;
|
|
|
|
|
|
|
|
public DiskFolderService(DiskFileService diskFileService, DiskFileMapper diskFileMapper) {
|
|
public DiskFolderService(DiskFileService diskFileService, DiskFileMapper diskFileMapper) {
|
|
@@ -31,16 +31,13 @@ public class DiskFolderService {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public synchronized Result createFolder(CreateFolder createFolder) {
|
|
public synchronized Result createFolder(CreateFolder createFolder) {
|
|
|
- String parentPath = FileUtil.getCanonicalPath(createFolder.getParentPath());
|
|
|
|
|
- String pid = "0";
|
|
|
|
|
- if (!parentPath.equals("/")) {
|
|
|
|
|
- DiskFile parentDiskFile = diskFileService.findByPath(parentPath);
|
|
|
|
|
- if (parentDiskFile == null) {
|
|
|
|
|
- return Result.fail("parent dir not exist");
|
|
|
|
|
- }
|
|
|
|
|
- pid = parentDiskFile.getFileId();
|
|
|
|
|
|
|
+ String pid = createFolder.getPid();
|
|
|
|
|
+ DiskFile parentDiskFile = diskFileService.findByFileId(pid);
|
|
|
|
|
+ if (parentDiskFile == null) {
|
|
|
|
|
+ return Result.fail("parent dir not exist");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ String parentPath = parentDiskFile.getPath();
|
|
|
String folderName = createFolder.getFolderName();
|
|
String folderName = createFolder.getFolderName();
|
|
|
String folderPath = String.format("%s/%s", parentPath, folderName);
|
|
String folderPath = String.format("%s/%s", parentPath, folderName);
|
|
|
String folderPath0 = FileUtil.getCanonicalPath(folderPath);
|
|
String folderPath0 = FileUtil.getCanonicalPath(folderPath);
|