提交 78c64a01 编写于 作者: 檀越@新空间's avatar 檀越@新空间 🐭

fix:删除没用的图片

上级 cd066e9b
package com.kwan.springbootkwan.utils; package com.kwan.springbootkwan.utils;
import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.date.StopWatch; import cn.hutool.core.date.StopWatch;
import com.alibaba.fastjson2.JSON; import com.alibaba.fastjson2.JSON;
...@@ -10,6 +9,7 @@ import com.google.common.io.Files; ...@@ -10,6 +9,7 @@ import com.google.common.io.Files;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.List; import java.util.List;
/** /**
...@@ -20,7 +20,6 @@ import java.util.List; ...@@ -20,7 +20,6 @@ import java.util.List;
* @date : 2023/2/8 10:45 * @date : 2023/2/8 10:45
*/ */
public class FileContainsUtil { public class FileContainsUtil {
/** /**
* 默认不存在 * 默认不存在
*/ */
...@@ -30,13 +29,21 @@ public class FileContainsUtil { ...@@ -30,13 +29,21 @@ public class FileContainsUtil {
*/ */
private static final String PIC_PATH = "/Users/qinyingjie/Documents/idea-workspace/blogimg/"; private static final String PIC_PATH = "/Users/qinyingjie/Documents/idea-workspace/blogimg/";
/** /**
* 博客路径 * 博客路径1
*/
private static final String BLOG_FOLDER1 = "/Users/qinyingjie/Documents/idea-workspace/blog/";
/**
* 博客路径2
*/ */
private static final String BLOG_FOLDER = "/Users/qinyingjie/Documents/idea-workspace/blog/"; private static final String BLOG_FOLDER2 = "/Users/qinyingjie/Documents/idea-workspace/study/blog/";
/** /**
* 白名单 * 白名单
*/ */
private static final String[] WHITELISTS = {"http://qinyingjie.top/blogImg/image-20230324112725149.png"}; private static final List<String> WHITELISTS = Arrays.asList(
"http://qinyingjie.top/blogImg/image-20230324112725149.png"
, "http://qinyingjie.top/blogImg/logo.png"
, "http://qinyingjie.top/blogImg/image-20230601124308164.png"
);
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {
StopWatch stopWatch = new StopWatch(); StopWatch stopWatch = new StopWatch();
...@@ -49,14 +56,7 @@ public class FileContainsUtil { ...@@ -49,14 +56,7 @@ public class FileContainsUtil {
if (CollectionUtil.isNotEmpty(picNames)) { if (CollectionUtil.isNotEmpty(picNames)) {
for (String picName : picNames) { for (String picName : picNames) {
//是白名单里面的图片,直接忽略 //是白名单里面的图片,直接忽略
boolean isWhite = false; if (WHITELISTS.contains(picName)) {
for (String whitelist : WHITELISTS) {
if (whitelist.contains(picName)) {
isWhite = true;
break;
}
}
if (isWhite) {
continue; continue;
} }
//默认不存在 //默认不存在
...@@ -65,7 +65,8 @@ public class FileContainsUtil { ...@@ -65,7 +65,8 @@ public class FileContainsUtil {
List<String> suffix = new ArrayList<>(); List<String> suffix = new ArrayList<>();
suffix.add(".md"); suffix.add(".md");
//包含某个字符串 //包含某个字符串
traverseFolder(BLOG_FOLDER, suffix, picName); traverseFolder(BLOG_FOLDER1, suffix, picName);
traverseFolder(BLOG_FOLDER2, suffix, picName);
//文件不存在 //文件不存在
if (!IS_EXIST) { if (!IS_EXIST) {
isNotExist.add(picName); isNotExist.add(picName);
...@@ -83,7 +84,7 @@ public class FileContainsUtil { ...@@ -83,7 +84,7 @@ public class FileContainsUtil {
* 获取文件 * 获取文件
* *
* @param path * @param path
* @param suffix * @param suffixs
* @param word * @param word
* @throws IOException * @throws IOException
*/ */
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册