[pim/trojita] src/Plugins/AbookAddressbook: Add method for getting abook dot directory path

Espen Sandøy Hustad <[email protected]>
Newsgroups gmane.comp.kde.cvs
Message-ID <[email protected]>
Git commit 8636a4169ebb86de8ce2926720e3d14f0895f59a by Espen Sandøy Hustad.
Committed on 03/08/2026 at 18:42.
Pushed by ehustad into branch 'master'.

Add method for getting abook dot directory path

To avoid duplication.

M  +10   -2    src/Plugins/AbookAddressbook/AbookAddressbook.cpp
M  +2    -0    src/Plugins/AbookAddressbook/AbookAddressbook.h

https://invent.kde.org/pim/trojita/-/commit/8636a4169ebb86de8ce2926720e3d14f0895f59a

diff --git a/src/Plugins/AbookAddressbook/AbookAddressbook.cpp b/src/Plugins/AbookAddressbook/AbookAddressbook.cpp
index 61445370c..9e808a48a 100644
--- a/src/Plugins/AbookAddressbook/AbookAddressbook.cpp
+++ b/src/Plugins/AbookAddressbook/AbookAddressbook.cpp
@@ -172,11 +172,19 @@ void AbookAddressbook::remonitorAdressbook()
     m_filesystemWatcher->addPath(QDir::homePath() + QLatin1String("/.abook/addressbook"));
 }
 
+QString AbookAddressbook::abookDirPath() const
+{
+    return QDir::homePath() + QStringLiteral("/.abook");
+}
+
 void AbookAddressbook::createAbookDir()
 {
-    if (!QDir::home().exists(QStringLiteral(".abook"))) {
-        QDir::home().mkdir(QStringLiteral(".abook"));
+    QDir dir(abookDirPath());
+    if (dir.exists()) {
+        return;
     }
+
+    dir.mkpath(dir.absolutePath());
 }
 
 void AbookAddressbook::updateConfigFile() const
diff --git a/src/Plugins/AbookAddressbook/AbookAddressbook.h b/src/Plugins/AbookAddressbook/AbookAddressbook.h
index d0cc412b9..fa00aaa65 100644
--- a/src/Plugins/AbookAddressbook/AbookAddressbook.h
+++ b/src/Plugins/AbookAddressbook/AbookAddressbook.h
@@ -77,6 +77,8 @@ private:
     void createAbookDBFile() const;
     void remonitorAdressbook();
 
+    [[nodiscard]] QString abookDirPath() const;
+
     QFileSystemWatcher *m_filesystemWatcher;
     QTimer *m_updateTimer;
     QStandardItemModel *m_contacts;
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.