diff --git a/src/main/java/com/kwan/springbootkwan/utils/FileContainsUtil.java b/src/main/java/com/kwan/springbootkwan/utils/FileContainsUtil.java index bd14c9b5f3cd06bb4ffb615dda8468fb83118fd0..d0e44d972cc6a3ccaea225db7e1e5ab98a6e9315 100644 --- a/src/main/java/com/kwan/springbootkwan/utils/FileContainsUtil.java +++ b/src/main/java/com/kwan/springbootkwan/utils/FileContainsUtil.java @@ -49,9 +49,7 @@ public class FileContainsUtil { * 图片白名单 */ private static final List PIC_PATH_WHITELISTS = Arrays.asList( - "image-20231023195334369.png", "logo.png" - , "image-20230601124308164.png" - , "image-20230822102858692.png" + "image-20231107143410634.png" ); public static void main(String[] args) throws Exception { @@ -82,7 +80,7 @@ public class FileContainsUtil { * @param isNotExist */ private static void moreThread(List> groupedPicNames, List isNotExist) { - // 创建并启动4个线程来处理每个组的任务 + // 创建并启动6个线程来处理每个组的任务 List threads = new ArrayList<>(); for (int i = 0; i < 6; i++) { final List group = groupedPicNames.get(i); @@ -90,31 +88,26 @@ public class FileContainsUtil { // 在这里执行处理图片组的任务 if (CollectionUtil.isNotEmpty(group)) { for (String picName : group) { - // 处理图片文件 picName //是白名单里面的图片,直接忽略 - for (String picPathWhitelist : PIC_PATH_WHITELISTS) { - if (picPathWhitelist.contains(picName)) { - continue; + if (!PIC_PATH_WHITELISTS.contains(picName)) { + //默认不存在 + IS_EXIST.set(false); + //包含某个字符串 + try { + traverseFolder(BLOG_FOLDER1, picName); + traverseFolder(BLOG_FOLDER2, picName); + traverseFolder(BLOG_FOLDER3, picName); + } catch (Exception e) { + e.printStackTrace(); + } + //文件不存在 + if (!IS_EXIST.get()) { + isNotExist.add(picName); + deletePic(PIC_PATH + picName); } - } - //默认不存在 - IS_EXIST.set(false); - //包含某个字符串 - try { - traverseFolder(BLOG_FOLDER1, picName); - traverseFolder(BLOG_FOLDER2, picName); - traverseFolder(BLOG_FOLDER3, picName); - } catch (Exception e) { - e.printStackTrace(); - } - //文件不存在 - if (!IS_EXIST.get()) { - isNotExist.add(picName); - deletePic(PIC_PATH + picName); } } } - }); thread.start(); threads.add(thread);