mirror of
https://github.com/LamGC/ContentGrabbingJi.git
synced 2025-07-01 12:57:26 +00:00
[Change] 调整数据存储的路径设置及存储目录参数名;
This commit is contained in:
@ -67,12 +67,12 @@ public class Main {
|
||||
}
|
||||
|
||||
// TODO: 需要修改参数名了, 大概改成类似于 workerDir这样的吧
|
||||
if(argsProp.containsKey("cqRootDir")) {
|
||||
log.info("cqRootDir: {}", argsProp.getValue("cqRootDir"));
|
||||
System.setProperty("cgj.cqRootDir", argsProp.getValue("cqRootDir"));
|
||||
if(argsProp.containsKey("botDataDir")) {
|
||||
log.info("botDataDir: {}", argsProp.getValue("botDataDir"));
|
||||
System.setProperty("cgj.botDataDir", argsProp.getValue("botDataDir"));
|
||||
} else {
|
||||
log.warn("未设置cqRootDir, 当前运行目录将作为酷Q机器人所在目录.");
|
||||
System.setProperty("cgj.cqRootDir", "./");
|
||||
log.warn("未设置botDataDir, 当前运行目录将作为酷Q机器人所在目录.");
|
||||
System.setProperty("cgj.botDataDir", "./");
|
||||
}
|
||||
|
||||
if(argsProp.containsKey("redisAddr")) {
|
||||
@ -83,7 +83,7 @@ public class Main {
|
||||
System.setProperty("cgj.redisAddress", "127.0.0.1");
|
||||
}
|
||||
|
||||
File cookieStoreFile = new File("cookies.store");
|
||||
File cookieStoreFile = new File(System.getProperty("cgj.botDataDir"), "cookies.store");
|
||||
if(!cookieStoreFile.exists()) {
|
||||
log.error("未找到cookies.store文件, 是否启动PixivLoginProxyServer? (yes/no)");
|
||||
Scanner scanner = new Scanner(System.in);
|
||||
@ -111,10 +111,10 @@ public class Main {
|
||||
|
||||
@Command
|
||||
public static void pluginMode(@Argument(name = "args", force = false) String argsStr) {
|
||||
if(!System.getProperty("cgj.cqRootDir").endsWith("\\") && !System.getProperty("cgj.cqRootDir").endsWith("/")) {
|
||||
System.setProperty("cgj.cqRootDir", System.getProperty("cgj.cqRootDir") + "/");
|
||||
if(!System.getProperty("cgj.botDataDir").endsWith("\\") && !System.getProperty("cgj.botDataDir").endsWith("/")) {
|
||||
System.setProperty("cgj.botDataDir", System.getProperty("cgj.botDataDir") + "/");
|
||||
}
|
||||
log.info("酷Q机器人根目录: {}", System.getProperty("cgj.cqRootDir"));
|
||||
log.info("酷Q机器人根目录: {}", System.getProperty("cgj.botDataDir"));
|
||||
CQConfig.init();
|
||||
Pattern pattern = Pattern.compile("/\\s*(\".+?\"|[^:\\s])+((\\s*:\\s*(\".+?\"|[^\\s])+)|)|(\".+?\"|[^\"\\s])+");
|
||||
Matcher matcher = pattern.matcher(Strings.nullToEmpty(argsStr));
|
||||
@ -366,7 +366,7 @@ public class Main {
|
||||
|
||||
private static void saveCookieStoreToFile() throws IOException {
|
||||
log.info("正在保存CookieStore...");
|
||||
File outputFile = new File("./cookies.store");
|
||||
File outputFile = new File(System.getProperty("cgj.botDataDir"), "cookies.store");
|
||||
if(!outputFile.exists() && !outputFile.delete() && !outputFile.createNewFile()){
|
||||
log.error("保存CookieStore失败.");
|
||||
return;
|
||||
|
@ -22,9 +22,9 @@ public class BotAdminCommandProcess {
|
||||
|
||||
private final static Logger log = LoggerFactory.getLogger(BotAdminCommandProcess.class.getSimpleName());
|
||||
|
||||
private final static File globalPropFile = new File("global.properties");
|
||||
private final static File globalPropFile = new File(System.getProperty("cgj.botDataDir"), "global.properties");
|
||||
|
||||
private final static File pushListFile = new File("pushList.json");
|
||||
private final static File pushListFile = new File(System.getProperty("cgj.botDataDir"), "pushList.json");
|
||||
|
||||
private final static Hashtable<Long, JsonObject> pushInfoMap = new Hashtable<>();
|
||||
|
||||
|
@ -41,7 +41,7 @@ public class BotCommandProcess {
|
||||
|
||||
private final static Logger log = LoggerFactory.getLogger(BotCommandProcess.class.getSimpleName());
|
||||
|
||||
private final static File imageStoreDir = new File(System.getProperty("cgj.cqRootDir"), "data/image/cgj/");
|
||||
private final static File imageStoreDir = new File(System.getProperty("cgj.botDataDir"), "data/image/cgj/");
|
||||
public final static Properties globalProp = new Properties();
|
||||
private final static Gson gson = new GsonBuilder()
|
||||
.serializeNulls()
|
||||
@ -76,7 +76,7 @@ public class BotCommandProcess {
|
||||
public static void initialize() {
|
||||
log.info("正在初始化...");
|
||||
|
||||
File globalPropFile = new File("./global.properties");
|
||||
File globalPropFile = new File(System.getProperty("cgj.botDataDir"), "global.properties");
|
||||
if(globalPropFile.exists() && globalPropFile.isFile()) {
|
||||
log.info("正在加载全局配置文件...");
|
||||
try {
|
||||
@ -590,7 +590,7 @@ public class BotCommandProcess {
|
||||
illustPreLoadDataCache.clear();
|
||||
pagesCache.clear();
|
||||
searchBodyCache.clear();
|
||||
File imageStoreDir = new File(System.getProperty("cgj.cqRootDir") + "data/image/cgj/");
|
||||
File imageStoreDir = new File(System.getProperty("cgj.botDataDir") + "data/image/cgj/");
|
||||
File[] listFiles = imageStoreDir.listFiles();
|
||||
if (listFiles == null) {
|
||||
log.debug("图片缓存目录为空或内部文件获取失败!");
|
||||
|
@ -34,7 +34,7 @@ public class MiraiMain implements Closeable {
|
||||
return;
|
||||
}
|
||||
|
||||
File botPropFile = new File("./bot.properties");
|
||||
File botPropFile = new File(System.getProperty("cgj.botDataDir"), "./bot.properties");
|
||||
try (Reader reader = new BufferedReader(new FileReader(botPropFile))) {
|
||||
botProperties.load(reader);
|
||||
} catch (IOException e) {
|
||||
|
Reference in New Issue
Block a user