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:
Lsyx-Good 2025-06-15 22:44:16 +08:00 committed by GitHub
parent 44658c9053
commit dffb2d34c1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -668,6 +668,8 @@ namespace NekoGui {
}
auto ruleSetArray = QJsonArray();
auto geoSitePath = GetCoreAssetDir("geosite.db");
auto geoIpPath = GetCoreAssetDir("geoip.db");
for (const auto &item: *neededRuleSets) {
ruleSetArray += QJsonObject{
{"type", "local"},
@ -677,7 +679,13 @@ namespace NekoGui {
};
if (QFile(QString(RULE_SETS_DIR + "/%1.srs").arg(item)).exists()) continue;
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) {
MW_show_log("Failed to generate rule set asset for " + item);
status->result->error = err;