mirror of
https://github.com/Mahdi-zarei/nekoray.git
synced 2025-12-28 04:41:23 +08:00
Solve failed to generate rule set (#447)
* Fix: Cannot find geoip/geosite.db to compile rule set when application path not exist core asset file * Improve: avoid repeatedly get core assert path
This commit is contained in:
parent
44658c9053
commit
dffb2d34c1
@ -668,6 +668,8 @@ namespace NekoGui {
|
|||||||
}
|
}
|
||||||
|
|
||||||
auto ruleSetArray = QJsonArray();
|
auto ruleSetArray = QJsonArray();
|
||||||
|
auto geoSitePath = GetCoreAssetDir("geosite.db");
|
||||||
|
auto geoIpPath = GetCoreAssetDir("geoip.db");
|
||||||
for (const auto &item: *neededRuleSets) {
|
for (const auto &item: *neededRuleSets) {
|
||||||
ruleSetArray += QJsonObject{
|
ruleSetArray += QJsonObject{
|
||||||
{"type", "local"},
|
{"type", "local"},
|
||||||
@ -677,7 +679,13 @@ namespace NekoGui {
|
|||||||
};
|
};
|
||||||
if (QFile(QString(RULE_SETS_DIR + "/%1.srs").arg(item)).exists()) continue;
|
if (QFile(QString(RULE_SETS_DIR + "/%1.srs").arg(item)).exists()) continue;
|
||||||
bool ok;
|
bool ok;
|
||||||
auto err = NekoGui_rpc::defaultClient->CompileGeoSet(&ok, item.contains("_IP") ? NekoGui_rpc::GeoRuleSetType::ip : NekoGui_rpc::GeoRuleSetType::site, item.toStdString(), GetBasePath());
|
auto mode = NekoGui_rpc::GeoRuleSetType::site;
|
||||||
|
auto geoAssertPath = geoSitePath;
|
||||||
|
if (item.contains("_IP")) {
|
||||||
|
mode = NekoGui_rpc::GeoRuleSetType::ip;
|
||||||
|
geoAssertPath = geoIpPath;
|
||||||
|
}
|
||||||
|
auto err = NekoGui_rpc::defaultClient->CompileGeoSet(&ok, mode, item.toStdString(), geoAssertPath);
|
||||||
if (!ok) {
|
if (!ok) {
|
||||||
MW_show_log("Failed to generate rule set asset for " + item);
|
MW_show_log("Failed to generate rule set asset for " + item);
|
||||||
status->result->error = err;
|
status->result->error = err;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user