From 6b041589250b27c99cc9063fd9e6c27104535b4e Mon Sep 17 00:00:00 2001 From: "Dirk-Jan C. Binnema" Date: Fri, 6 Jan 2023 19:48:40 +0200 Subject: [PATCH] mu-store: create mu cache path if needed --- lib/mu-store.cc | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/mu-store.cc b/lib/mu-store.cc index d135febf..f34b6d40 100644 --- a/lib/mu-store.cc +++ b/lib/mu-store.cc @@ -116,6 +116,11 @@ struct Store::Private { * backstop*/ g_setenv("XAPIAN_FLUSH_THRESHOLD", "500000", 1); + if (g_mkdir_with_parents(db_path.c_str(), 0700) != 0) + throw Mu::Error(Error::Code::Internal, + "failed to create database dir %s: %s", + db_path.c_str(), ::strerror(errno)); + switch (opts) { case XapianOpts::ReadOnly: return std::make_unique(db_path); @@ -135,6 +140,8 @@ struct Store::Private { } catch (const Xapian::DatabaseError& xde) { throw Mu::Error(Error::Code::Store, "%s", xde.get_msg().c_str()); + } catch (const Mu::Error& me) { + throw; } catch (...) { throw Mu::Error(Error::Code::Internal, "something went wrong when opening store @ %s",