From d5baa6ea163058129f35f9b8657ccdf5e21e7a63 Mon Sep 17 00:00:00 2001
From: 13693261870 <252740454@qq.com>
Date: 星期六, 19 十一月 2022 10:41:40 +0800
Subject: [PATCH] 1

---
 src/main/java/com/lf/server/helper/PathHelper.java |   28 +++++++++++++++++++++-------
 1 files changed, 21 insertions(+), 7 deletions(-)

diff --git a/src/main/java/com/lf/server/helper/PathHelper.java b/src/main/java/com/lf/server/helper/PathHelper.java
index 52bb793..1d98161 100644
--- a/src/main/java/com/lf/server/helper/PathHelper.java
+++ b/src/main/java/com/lf/server/helper/PathHelper.java
@@ -65,7 +65,7 @@
             }
 
             File[] files = file.listFiles();
-            if (files.length < SettingData.MAX_FILES) {
+            if (null == files || files.length < SettingData.MAX_FILES) {
                 return subPath;
             }
 
@@ -105,20 +105,29 @@
      */
     public String getTempPath() {
         String tempName = StringHelper.YMDHMS2_FORMAT.format(new Date());
-        String tempPath = config.getTempPath();
-        String path = tempPath + File.separator + tempName;
+        String path = config.getTempPath() + File.separator + tempName;
 
         File file = new File(path);
         if (!file.exists() && !file.isDirectory()) {
             file.mkdirs();
         }
 
-        double ran = Math.random() * 99;
-        if (ran > D90) {
-            deleteOldPath(tempPath);
+        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 path;
+        return tempName;
     }
 
     /**
@@ -142,6 +151,11 @@
      */
     public void deleteOldPath(String tempPath) {
         try {
+            double ran = Math.random() * 99;
+            if (ran < D90) {
+                return;
+            }
+
             File file = new File(tempPath);
             String str = StringHelper.YMD__FORMAT.format(new Date());
 

--
Gitblit v1.9.3