From 01978f583ae1d2878830ccd8b58c4b3e0c39f257 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Niccol=C3=B2=20Venerandi?= <niccolo@venerandi.com>
Date: Thu, 29 May 2025 07:25:03 +0000
Subject: [PATCH] Do not track cache partitions with freespacenotifier
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

BUG:504423


(cherry picked from commit f4a08099d0aae466f06f0094498cc593c8ce4532)

e033ef89 Do not track cache partitions with freespacenotifier
5203019a Apply 1 suggestion(s) to 1 file(s)

Co-authored-by: Niccolò Venerandi <niccolo@venerandi.com>
---
 freespacenotifier/module.cpp | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/freespacenotifier/module.cpp b/freespacenotifier/module.cpp
index 3d8e06c0a4..1700a3695d 100644
--- a/freespacenotifier/module.cpp
+++ b/freespacenotifier/module.cpp
@@ -19,6 +19,7 @@
 #include <Solid/StorageVolume>
 
 #include <QDir>
+#include <QFile>
 
 #include "kded_interface.h"
 
@@ -74,7 +75,11 @@ void FreeSpaceNotifierModule::onNewSolidDevice(const QString &udi)
     if (auto generic = device.as<Solid::GenericInterface>()) {
         isReadOnly = generic->property(QStringLiteral("ReadOnly")).toBool();
     }
-    if (isReadOnly) {
+    // Cache devices should be marked through a
+    // CACHEDIR.TAG file to avoid indexing; see
+    // https://bford.info/cachedir/ for reference.
+    const bool isCache = QFile::exists(QDir(access->filePath()).filePath(QStringLiteral("CACHEDIR.TAG")));
+    if (isReadOnly || isCache) {
         return;
     }
 
-- 
GitLab

