[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [amarok] src/core-impl/collections/umscollection: Do not create duplicate UMS collections for encryp
From: Mark Kretschmann <kretschmann () kde ! org>
Date: 2013-08-16 7:16:28
Message-ID: E1VAEGq-0006c4-AX () scm ! kde ! org
[Download RAW message or body]
Git commit 9d12f655f1ac1f518aa67f2bba1dfcad05b673fa by Mark Kretschmann, on behalf of \
Frank Meerkoetter. Committed on 16/08/2013 at 07:14.
Pushed by markey into branch 'master'.
Do not create duplicate UMS collections for encrypted volumes.
When I plug an encrypted USB-stick amarok is creating two UMS collections for it. \
Both have the same mount point.
$ solid-hardware list details
[...]
udi = '/org/freedesktop/UDisks/devices/dm_2d5'
parent = '/org/freedesktop/UDisks/devices/sdd1' (string)
vendor = '' (string)
product = '' (string)
description = '29.9 GiB Removable Media' (string)
Block.major = 252 (0xfc) (int)
Block.minor = 5 (0x5) (int)
Block.device = '/dev/dm-5' (string)
StorageAccess.accessible = true (bool)
StorageAccess.filePath = '/media/62a745fa-6350-4ee5-ba37-0462dfa3530f' (string)
StorageAccess.ignored = false (bool)
StorageVolume.ignored = false (bool)
StorageVolume.usage = 'FileSystem' (0x2) (enum)
StorageVolume.fsType = 'ext4' (string)
StorageVolume.label = '' (string)
StorageVolume.uuid = '62a745fa-6350-4ee5-ba37-0462dfa3530f' (string)
StorageVolume.size = 32125222912 (0x77ad00000) (qulonglong)
[...]
udi = '/org/freedesktop/UDisks/devices/sdd1'
parent = '/org/freedesktop/UDisks/devices/sdd' (string)
vendor = 'JetFlash' (string)
product = 'Transcend 32GB' (string)
description = '29.9 GiB Encrypted Container' (string)
Block.major = 8 (0x8) (int)
Block.minor = 49 (0x31) (int)
Block.device = '/dev/sdd1' (string)
StorageAccess.accessible = true (bool)
StorageAccess.filePath = '/media/62a745fa-6350-4ee5-ba37-0462dfa3530f' (string)
StorageAccess.ignored = false (bool)
StorageVolume.ignored = false (bool)
StorageVolume.usage = 'Encrypted' (0x5) (enum)
StorageVolume.fsType = 'crypto_LUKS' (string)
StorageVolume.label = '' (string)
StorageVolume.uuid = '1a38165b-2eee-41d0-acd1-6d34032f47fd' (string)
StorageVolume.size = 32127320064 (0x77af00000) (qulonglong)
This patch is filtering out the storage volume where the usage field is set to \
"Encrypted" (as opposed to "Filesystem").
REVIEW: 112040
M +25 -0 src/core-impl/collections/umscollection/UmsCollection.cpp
M +5 -0 src/core-impl/collections/umscollection/UmsCollection.h
http://commits.kde.org/amarok/9d12f655f1ac1f518aa67f2bba1dfcad05b673fa
diff --git a/src/core-impl/collections/umscollection/UmsCollection.cpp \
b/src/core-impl/collections/umscollection/UmsCollection.cpp index fc8c862..ad38461 \
100644
--- a/src/core-impl/collections/umscollection/UmsCollection.cpp
+++ b/src/core-impl/collections/umscollection/UmsCollection.cpp
@@ -131,6 +131,28 @@ UmsCollectionFactory::slotCollectionDestroyed( QObject \
*collection ) }
bool
+UmsCollectionFactory::isNonFilesystemVolume( const Solid::Device &device ) const
+{
+ using namespace Solid;
+ const StorageVolume *sv = device.as<StorageVolume>();
+ if( !sv )
+ return false;
+
+ switch( sv->usage() )
+ {
+ case StorageVolume::Other:
+ case StorageVolume::Unused:
+ case StorageVolume::PartitionTable:
+ case StorageVolume::Encrypted:
+ case StorageVolume::Raid:
+ return true;
+ case StorageVolume::FileSystem:
+ return false;
+ }
+ return false;
+}
+
+bool
UmsCollectionFactory::identifySolidDevice( const QString &udi ) const
{
Solid::Device device( udi );
@@ -149,6 +171,9 @@ UmsCollectionFactory::identifySolidDevice( const QString &udi ) \
const return false;
}
+ if( isNonFilesystemVolume( device ) )
+ return false;
+
// check whether there is parent USB StorageDrive device
while( device.isValid() )
{
diff --git a/src/core-impl/collections/umscollection/UmsCollection.h \
b/src/core-impl/collections/umscollection/UmsCollection.h index 0bc620c..ac49f82 \
100644
--- a/src/core-impl/collections/umscollection/UmsCollection.h
+++ b/src/core-impl/collections/umscollection/UmsCollection.h
@@ -85,6 +85,11 @@ class UmsCollectionFactory : public CollectionFactory
bool identifySolidDevice( const QString &udi ) const;
/**
+ * Returns true if this is a volume that isn't containing a filesystem.
+ */
+ bool isNonFilesystemVolume( const Solid::Device &device ) const;
+
+ /**
* Attempts to create appropriate collection for already identified solid \
device
* @param udi. Should emit newCollection() if the collection was \
successfully
* created and should become visible to the user.
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic