[Change] 调整数据存储的路径设置及存储目录参数名;

This commit is contained in:
2020-04-30 17:51:57 +08:00
parent e8fda3214b
commit a28cb142b4
4 changed files with 16 additions and 16 deletions

View File

@ -67,12 +67,12 @@ public class Main {
} }
// TODO: 需要修改参数名了, 大概改成类似于 workerDir这样的吧 // TODO: 需要修改参数名了, 大概改成类似于 workerDir这样的吧
if(argsProp.containsKey("cqRootDir")) { if(argsProp.containsKey("botDataDir")) {
log.info("cqRootDir: {}", argsProp.getValue("cqRootDir")); log.info("botDataDir: {}", argsProp.getValue("botDataDir"));
System.setProperty("cgj.cqRootDir", argsProp.getValue("cqRootDir")); System.setProperty("cgj.botDataDir", argsProp.getValue("botDataDir"));
} else { } else {
log.warn("未设置cqRootDir, 当前运行目录将作为酷Q机器人所在目录."); log.warn("未设置botDataDir, 当前运行目录将作为酷Q机器人所在目录.");
System.setProperty("cgj.cqRootDir", "./"); System.setProperty("cgj.botDataDir", "./");
} }
if(argsProp.containsKey("redisAddr")) { if(argsProp.containsKey("redisAddr")) {
@ -83,7 +83,7 @@ public class Main {
System.setProperty("cgj.redisAddress", "127.0.0.1"); 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()) { if(!cookieStoreFile.exists()) {
log.error("未找到cookies.store文件, 是否启动PixivLoginProxyServer? (yes/no)"); log.error("未找到cookies.store文件, 是否启动PixivLoginProxyServer? (yes/no)");
Scanner scanner = new Scanner(System.in); Scanner scanner = new Scanner(System.in);
@ -111,10 +111,10 @@ public class Main {
@Command @Command
public static void pluginMode(@Argument(name = "args", force = false) String argsStr) { public static void pluginMode(@Argument(name = "args", force = false) String argsStr) {
if(!System.getProperty("cgj.cqRootDir").endsWith("\\") && !System.getProperty("cgj.cqRootDir").endsWith("/")) { if(!System.getProperty("cgj.botDataDir").endsWith("\\") && !System.getProperty("cgj.botDataDir").endsWith("/")) {
System.setProperty("cgj.cqRootDir", System.getProperty("cgj.cqRootDir") + "/"); System.setProperty("cgj.botDataDir", System.getProperty("cgj.botDataDir") + "/");
} }
log.info("酷Q机器人根目录: {}", System.getProperty("cgj.cqRootDir")); log.info("酷Q机器人根目录: {}", System.getProperty("cgj.botDataDir"));
CQConfig.init(); CQConfig.init();
Pattern pattern = Pattern.compile("/\\s*(\".+?\"|[^:\\s])+((\\s*:\\s*(\".+?\"|[^\\s])+)|)|(\".+?\"|[^\"\\s])+"); Pattern pattern = Pattern.compile("/\\s*(\".+?\"|[^:\\s])+((\\s*:\\s*(\".+?\"|[^\\s])+)|)|(\".+?\"|[^\"\\s])+");
Matcher matcher = pattern.matcher(Strings.nullToEmpty(argsStr)); Matcher matcher = pattern.matcher(Strings.nullToEmpty(argsStr));
@ -366,7 +366,7 @@ public class Main {
private static void saveCookieStoreToFile() throws IOException { private static void saveCookieStoreToFile() throws IOException {
log.info("正在保存CookieStore..."); 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()){ if(!outputFile.exists() && !outputFile.delete() && !outputFile.createNewFile()){
log.error("保存CookieStore失败."); log.error("保存CookieStore失败.");
return; return;

View File

@ -22,9 +22,9 @@ public class BotAdminCommandProcess {
private final static Logger log = LoggerFactory.getLogger(BotAdminCommandProcess.class.getSimpleName()); 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<>(); private final static Hashtable<Long, JsonObject> pushInfoMap = new Hashtable<>();

View File

@ -41,7 +41,7 @@ public class BotCommandProcess {
private final static Logger log = LoggerFactory.getLogger(BotCommandProcess.class.getSimpleName()); 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(); public final static Properties globalProp = new Properties();
private final static Gson gson = new GsonBuilder() private final static Gson gson = new GsonBuilder()
.serializeNulls() .serializeNulls()
@ -76,7 +76,7 @@ public class BotCommandProcess {
public static void initialize() { public static void initialize() {
log.info("正在初始化..."); log.info("正在初始化...");
File globalPropFile = new File("./global.properties"); File globalPropFile = new File(System.getProperty("cgj.botDataDir"), "global.properties");
if(globalPropFile.exists() && globalPropFile.isFile()) { if(globalPropFile.exists() && globalPropFile.isFile()) {
log.info("正在加载全局配置文件..."); log.info("正在加载全局配置文件...");
try { try {
@ -590,7 +590,7 @@ public class BotCommandProcess {
illustPreLoadDataCache.clear(); illustPreLoadDataCache.clear();
pagesCache.clear(); pagesCache.clear();
searchBodyCache.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(); File[] listFiles = imageStoreDir.listFiles();
if (listFiles == null) { if (listFiles == null) {
log.debug("图片缓存目录为空或内部文件获取失败!"); log.debug("图片缓存目录为空或内部文件获取失败!");

View File

@ -34,7 +34,7 @@ public class MiraiMain implements Closeable {
return; 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))) { try (Reader reader = new BufferedReader(new FileReader(botPropFile))) {
botProperties.load(reader); botProperties.load(reader);
} catch (IOException e) { } catch (IOException e) {