From c70be7ed8b71798cb940920e9ef3380be646e87a Mon Sep 17 00:00:00 2001
From: Adriaan de Groot <groot@kde.org>
Date: Thu, 13 Feb 2025 21:54:22 +0100
Subject: [PATCH] [partition] Use the doNotClose setting

---
 src/modules/partition/jobs/ClearMountsJob.cpp | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)

diff --git a/src/modules/partition/jobs/ClearMountsJob.cpp b/src/modules/partition/jobs/ClearMountsJob.cpp
index 2fbafb5dc7..b4ebfebf49 100644
--- a/src/modules/partition/jobs/ClearMountsJob.cpp
+++ b/src/modules/partition/jobs/ClearMountsJob.cpp
@@ -123,6 +123,23 @@ isSpecial( const QString& baseName )
     return specialForFedora || specialMapperControl || specialVentoy;
 }
 
+static inline bool
+matchesExceptions( const QStringList& mapperExceptions, const QString& basename )
+{
+    for ( const auto& e : mapperExceptions )
+    {
+        if ( basename == e )
+        {
+            return true;
+        }
+        if ( e.endsWith( '*' ) && basename.startsWith( e.left( e.length() - 1 ) ) )
+        {
+            return true;
+        }
+    }
+    return false;
+}
+
 /** @brief Returns a list of unneeded crypto devices
  *
  * These are the crypto devices to unmount and close; some are "needed"
@@ -139,7 +156,7 @@ getCryptoDevices( const QStringList& mapperExceptions )
     for ( const QFileInfo& fi : fiList )
     {
         QString baseName = fi.baseName();
-        if ( isSpecial( baseName ) || mapperExceptions.contains( baseName ) )
+        if ( isSpecial( baseName ) || matchesExceptions( mapperExceptions, baseName ) )
         {
             continue;
         }
-- 
GitLab