diff --git a/lib/index/mu-indexer.cc b/lib/index/mu-indexer.cc index fbb52741..dc1bdece 100644 --- a/lib/index/mu-indexer.cc +++ b/lib/index/mu-indexer.cc @@ -242,7 +242,7 @@ Indexer::Private::start(const Indexer::Config& conf) else max_workers_ = conf.max_threads; - g_debug ("starting indexer with up to %zu threads", max_workers_); + g_debug ("starting indexer with up to %zu worker threads", max_workers_); scan_done_ = false; workers_.emplace_back(std::thread([this]{worker();})); @@ -255,13 +255,14 @@ Indexer::Private::start(const Indexer::Config& conf) if (conf_.scan) { g_debug("starting scanner"); - if (!scanner_.start()) { + const auto started{scanner_.start()}; + clean_done_ = scan_done_ = true; // so listeners will stop. + + if (!started) { g_warning ("failed to start scanner"); return; - } - - scan_done_ = true; - g_debug ("scanner finished"); + } else + g_debug ("scanner finished"); } if (conf_.cleanup) { @@ -314,6 +315,12 @@ Indexer::~Indexer() = default; bool Indexer::start(const Indexer::Config& conf) { + const auto mdir{priv_->store_.metadata().root_maildir}; + if (G_UNLIKELY(access (mdir.c_str(), R_OK) != 0)) { + g_critical("'%s' is not readable: %s", mdir.c_str(), strerror (errno)); + return false; + } + std::lock_guard l(priv_->lock_); if (is_running()) return true; diff --git a/mu/mu-cmd-index.cc b/mu/mu-cmd-index.cc index f5bcaa66..2db4d2d1 100644 --- a/mu/mu-cmd-index.cc +++ b/mu/mu-cmd-index.cc @@ -98,6 +98,13 @@ mu_cmd_index (Mu::Store& store, const MuConfig *opts, GError **err) return MU_ERROR; } + const auto mdir{store.metadata().root_maildir}; + if (G_UNLIKELY(access (mdir.c_str(), R_OK) != 0)) { + mu_util_g_set_error(err, MU_ERROR_FILE, + "'%s' is not readable: %s", mdir.c_str(), strerror (errno)); + return MU_ERROR; + } + MaybeAnsi col{!opts->nocolor}; using Color = MaybeAnsi::Color; if (!opts->quiet) {