管道基础大数据平台系统开发-【后端】-Server
1
13693261870
2023-02-10 014639637a80b0549cc0aee00b9a9670fb57827c
src/main/java/com/lf/server/helper/PathHelper.java
@@ -25,7 +25,7 @@
    private static int sharePath = 1;
    private final static double D90 = 90;
    private final static double D85 = 85;
    private final static Log log = LogFactory.getLog(PathHelper.class);
@@ -112,22 +112,9 @@
            file.mkdirs();
        }
        deleteOldPath(config.getTempPath());
        return path;
    }
    /**
     * 获取临时路径名称
     */
    public String getTempPathName() {
        String tempName = StringHelper.YMDHMS2_FORMAT.format(new Date());
        String path = config.getTempPath() + File.separator + tempName;
        File file = new File(path);
        if (!file.exists() && !file.isDirectory()) {
            file.mkdirs();
        }
        return tempName;
    }
    /**
@@ -143,7 +130,26 @@
            }
        }
        deleteOldPath(config.getTempPath());
        return getTempPath();
    }
    /**
     * 获取临时路径名称
     */
    public String getTempPathName() {
        String tempName = StringHelper.YMDHMS2_FORMAT.format(new Date());
        String path = config.getTempPath() + File.separator + tempName;
        File file = new File(path);
        if (!file.exists() && !file.isDirectory()) {
            file.mkdirs();
        }
        deleteOldPath(config.getTempPath());
        return tempName;
    }
    /**
@@ -152,16 +158,16 @@
    public void deleteOldPath(String tempPath) {
        try {
            double ran = Math.random() * 99;
            if (ran < D90) {
            if (ran < D85) {
                return;
            }
            File file = new File(tempPath);
            String str = StringHelper.YMD__FORMAT.format(new Date());
            String str = StringHelper.YMD2_FORMAT.format(new Date());
            File[] files = file.listFiles();
            for (File f : files) {
                if (f.getPath().indexOf(str) > -1) {
                if (f.getPath().contains(str)) {
                    continue;
                }