Skip to content

Commit

Permalink
TgBot++: SendMediaToChat: Again, value unloadDatabase
Browse files Browse the repository at this point in the history
  • Loading branch information
Royna2544 committed Jun 28, 2024
1 parent 1234604 commit cc189d1
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/database/utils/SendMediaToChat.cc
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,18 @@ int main(int argc, char* const* argv) {
if (argc != 3) {
_usage(EXIT_SUCCESS);
}
if (!backend->loadDBFromConfig()) {
LOG(ERROR) << "Failed to load DB from config";
return EXIT_FAILURE;
}
if (!try_parse(argv[1], &chatId)) {
LOG(ERROR) << "Failed to convert '" << argv[1] << "' to ChatId";
_usage(EXIT_FAILURE);
}
if (!backend->loadDBFromConfig()) {
LOG(ERROR) << "Failed to load DB from config";
return EXIT_FAILURE;
}
auto info = backend->queryMediaInfo(argv[2]);
if (!info.has_value()) {
LOG(ERROR) << "Failed to find entry for name '" << argv[2] << "'";
backend->unloadDatabase();
return EXIT_FAILURE;
} else {
LOG(INFO) << "Found, sending (fileid " << info->mediaId << ") to chat "
Expand All @@ -53,4 +54,5 @@ int main(int argc, char* const* argv) {
SocketClientWrapper wrapper(
SocketInterfaceBase::LocalHelper::getSocketPath());
wrapper->writeAsClientToSocket(pkt.toSocketData());
backend->unloadDatabase();
}

0 comments on commit cc189d1

Please sign in to comment.