From a088d7cf86c5b04b8c959047ad7f281005ed8188 Mon Sep 17 00:00:00 2001 From: JunjieBai Date: Thu, 20 Oct 2022 11:16:10 +0800 Subject: [PATCH] Add the support for nvme device. --- .../dirwatcher/dir-watcher.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/ukui-search-service-dir-manager/dirwatcher/dir-watcher.cpp b/ukui-search-service-dir-manager/dirwatcher/dir-watcher.cpp index 2ddd31c..42b7695 100644 --- a/ukui-search-service-dir-manager/dirwatcher/dir-watcher.cpp +++ b/ukui-search-service-dir-manager/dirwatcher/dir-watcher.cpp @@ -213,7 +213,7 @@ void DirWatcher::mountAddCallback(GVolumeMonitor *monitor, GMount *gmount, DirWa if (volume) { bool canEject = g_volume_can_eject(volume); QString devName = g_volume_get_identifier(volume, G_VOLUME_IDENTIFIER_KIND_UNIX_DEVICE); - if (canEject and devName.contains(QRegExp("/sd[a-z][1-9]"))) { + if (canEject and devName.contains(QRegExp("/nvme[0-9]+n[0-9]+p[0-9]+|/sd[a-z][0-9]+"))) { QMutexLocker locker(&s_mutex); pThis->m_currentUDiskDeviceList.append(devName.section("/", -1)); } @@ -478,7 +478,7 @@ void DirWatcher::initData() GVolume *volume = (GVolume*)g_list_nth_data(list, i); QString udiskDevName = g_volume_get_identifier(volume, G_VOLUME_IDENTIFIER_KIND_UNIX_DEVICE); bool canEject = g_volume_can_eject(volume); - if (canEject and udiskDevName.contains(QRegExp("/sd[a-z][1-9]"))) { + if (canEject and udiskDevName.contains(QRegExp("/nvme[0-9]+n[0-9]+p[0-9]+|/sd[a-z][0-9]+"))) { qDebug() << "udiskDevName:" << udiskDevName.section("/",-1); m_currentUDiskDeviceList.append(udiskDevName.section("/",-1)); } @@ -523,8 +523,8 @@ void DirWatcher::handleDisk() m_currentMountedDeviceInfo.clear(); m_repeatedlyMountedDeviceInfo.clear(); for (QStorageInfo &storage: QStorageInfo::mountedVolumes()) { - //遍历当前系统所有挂载的,且以sd*开头的存储设备 - if (storage.isValid() and storage.isReady() and QString(storage.device()).contains(QRegExp("/sd[a-z][1-9]"))) { + //遍历当前系统所有挂载的,且以sd*和nvme开头的存储设备 + if (storage.isValid() and storage.isReady() and QString(storage.device()).contains(QRegExp("/nvme[0-9]+n[0-9]+p[0-9]+|/sd[a-z][0-9]+"))) { m_currentMountedDeviceInfo[storage.device()].append(storage.rootPath()); //存储非子卷的重复挂载设备 if (m_currentMountedDeviceInfo.value(storage.device()).length() > 1 and storage.subvolume().isEmpty()) { @@ -578,7 +578,7 @@ void DirWatcher::handleDisk() void DirWatcher::handleAddedUDiskDevice(QDBusMessage msg) { QDBusObjectPath objPath = msg.arguments().at(0).value(); - if (objPath.path().contains(QRegExp("/sd[a-z][1-9]"))) { + if (objPath.path().contains(QRegExp("/nvme[0-9]+n[0-9]+p[0-9]+|/sd[a-z][0-9]+"))) { QMutexLocker locker(&s_mutex); m_currentUDiskDeviceList.append(objPath.path().section("/",-1)); qDebug() << "Add Udisk:" << m_currentUDiskDeviceList; @@ -589,7 +589,7 @@ void DirWatcher::handleRemovedUDiskDevice(QDBusMessage msg) { Q_EMIT this->udiskRemoved(); QDBusObjectPath objPath = msg.arguments().at(0).value(); - if (objPath.path().contains(QRegExp("/sd[a-z][1-9]"))) { + if (objPath.path().contains(QRegExp("/nvme[0-9]+n[0-9]+p[0-9]+|/sd[a-z][0-9]+"))) { QMutexLocker locker(&s_mutex); m_removedUDiskDevice = objPath.path().section("/",-1); m_currentUDiskDeviceList.removeAll(m_removedUDiskDevice);