From 3998b759f75b3f58654c27686513e0b314e52043 Mon Sep 17 00:00:00 2001 From: casey langen Date: Sat, 20 Aug 2022 00:05:59 -0700 Subject: [PATCH] Use SIGUSR1 to rescan library in musikcubed --- CHANGELOG.txt | 1 + src/musikcubed/main.cpp | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 74b0bf950..cea29c75d 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -5,6 +5,7 @@ * fixed `musikdroid` app notification on Android 13 devices. * updated `musikdroid` dependencies and tooling, fixed a few warnings. * merged latest upstream `PDCurses` code for Windows builds. +* sending `musikcubed` a SIGUSR1 will trigger a library rescan. -------------------------------------------------------------------------------- diff --git a/src/musikcubed/main.cpp b/src/musikcubed/main.cpp index fbe9a7201..a6acdfb24 100644 --- a/src/musikcubed/main.cpp +++ b/src/musikcubed/main.cpp @@ -270,6 +270,12 @@ static void initUtf8() { boost::filesystem::path::imbue(utf8Locale); } +static void rescanHandler(int signal) { + debug::info("daemon", "received SIGUSR1, rescanning the library..."); + auto library = LibraryFactory::Instance().DefaultLocalLibrary(); + library->Indexer()->Schedule(IIndexer::SyncType::All); +} + int main(int argc, char** argv) { initUtf8(); std::cout << "\n using lockfile at: " << getLockfileFn(); @@ -280,6 +286,8 @@ int main(int argc, char** argv) { srand((unsigned int) time(0)); + std::signal(SIGUSR1, rescanHandler); + plugin::Init(); EvMessageQueue messageQueue;