管道基础大数据平台系统开发-【后端】-Server
1
13693261870
2023-01-12 d1d61f6f9ae0c992e4368e7df72dc9ad8ab57e40
src/main/java/com/lf/server/service/data/UploadService.java
@@ -219,24 +219,23 @@
        MetaEntity old = metaService.selectByGuid(mf.getGuid());
        if (null != old) {
            mf.setMsg("文件已存在");
            mf.setPath(old.getPath());
            file.delete();
            return 0;
        }
        String uploadPath = pathHelper.getUploadFullPath();
        String targetPath = uploadPath + File.separator + mf.getGuid() + mf.getExtName();
        String subPath = FileHelper.getRelativePath(targetPath);
        File newFile = new File(targetPath);
        if (newFile.exists()) {
            mf.setMsg("文件已存在");
            mf.setPath(subPath);
            file.delete();
            return 0;
        }
        file.renameTo(newFile);
        String subPath = FileHelper.getRelativePath(targetPath);
        mf.setPath(subPath);
        return 1;
@@ -290,17 +289,18 @@
        MetaEntity old = metaService.selectByGuid(mf.getGuid());
        if (null != old) {
            mf.setMsg("文件已存在");
            mf.setPath(old.getPath());
            FileHelper.deleteFiles(file);
            return;
        }
        String uploadPath = pathHelper.getUploadFullPath();
        String targetPath = uploadPath + File.separator + mf.getGuid() + mf.getExtName();
        String subPath = FileHelper.getRelativePath(targetPath);
        File newFile = new File(targetPath);
        if (newFile.exists() && newFile.isDirectory()) {
            mf.setMsg("文件已存在");
            mf.setPath(subPath);
            FileHelper.deleteFiles(file);
            return;
        }
@@ -312,11 +312,9 @@
        }
        for (File f : files) {
            String subPath = targetPath + File.separator + FileHelper.getFileName(f.getPath());
            f.renameTo(new File(subPath));
            String subFile = targetPath + File.separator + FileHelper.getFileName(f.getPath());
            f.renameTo(new File(subFile));
        }
        String subPath = FileHelper.getRelativePath(targetPath);
        mf.setPath(subPath);
    }