[FIX] Fix minor DB fuckup with tools

Used to open a flatfile database whenever it couldn't find an LMDB one,
which obviously caused *problems*
This commit is contained in:
lda 2025-02-08 08:45:21 +00:00
commit 1936be0078
2 changed files with 20 additions and 21 deletions

View file

@ -89,31 +89,30 @@ Main(Array *args, HashMap *env)
glob = ArrayGet(args, 2); glob = ArrayGet(args, 2);
parsee = GetDB(db_path); parsee = GetDB(db_path);
if (parsee) if (!parsee)
{ {
Log(LOG_ERR, "%s: couldn't open config '%s' or couldnt edit DB", exec, db_path);
(void) env;
return EXIT_FAILURE;
}
if (glob) if (glob)
{ {
Log(LOG_NOTICE, "Adding glob '%s' to database %s", glob, db_path); Log(LOG_NOTICE, "Adding glob '%s' to database %s", glob, db_path);
AddAdmin(parsee, glob); AddAdmin(parsee, glob);
Log(LOG_INFO, "Successfully added glob %s.", glob); Log(LOG_INFO, "Successfully added glob %s.", glob);
Log(LOG_INFO, "*I'm jealous of all these admins!*"); Log(LOG_INFO, "*I'm jealous of all these admins!*");
DbClose(parsee);
return EXIT_SUCCESS;
}
/* List admins */
Log(LOG_INFO, "Admin list:");
LogConfigIndent(LogConfigGlobal());
ListAdmins(parsee);
LogConfigUnindent(LogConfigGlobal());
DbClose(parsee); DbClose(parsee);
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }
Log(LOG_ERR, "%s: couldn't open config '%s' or couldnt edit DB", exec, db_path); /* List admins */
(void) env; Log(LOG_INFO, "Admin list:");
return EXIT_FAILURE; LogConfigIndent(LogConfigGlobal());
ListAdmins(parsee);
LogConfigUnindent(LogConfigGlobal());
DbClose(parsee);
return EXIT_SUCCESS;
} }

View file

@ -108,7 +108,7 @@ GetDB(char *config)
{ {
ret = DbOpenLMDB(db_path, lmdb_size); ret = DbOpenLMDB(db_path, lmdb_size);
} }
if (!ret) else
{ {
ret = DbOpen(db_path, 0); ret = DbOpen(db_path, 0);
} }