Skip to content

Commit

Permalink
fix: [sidebar] sidebar not hidden internal disks
Browse files Browse the repository at this point in the history
  • Loading branch information
itsXuSt authored and deepin-bot[bot] committed Jan 8, 2024
1 parent d697e1e commit fc76485
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 8 deletions.
8 changes: 1 addition & 7 deletions src/dfm-base/base/device/devicemanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,14 +81,8 @@ QStringList DeviceManager::getAllBlockDevID(DeviceQueryOptions opts)
if (opts.testFlag(DeviceQueryOption::kOptical)
&& !data.value(DeviceProperty::kOptical).toBool())
continue;

bool isSystem = data.value(DeviceProperty::kHintSystem).toBool()
|| data.value(DeviceProperty::kConnectionBus).toString() != "usb";
if (data.value(DeviceProperty::kOpticalDrive).toBool())
isSystem = false;

if (opts.testFlag(DeviceQueryOption::kSystem)
&& !isSystem)
&& !DeviceUtils::isSystemDisk(data))
continue;
if (opts.testFlag(DeviceQueryOption::kLoop)
&& !data.value(DeviceProperty::kIsLoopDevice).toBool())
Expand Down
20 changes: 20 additions & 0 deletions src/dfm-base/base/device/deviceutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -672,6 +672,26 @@ QString DeviceUtils::bindPathTransform(const QString &path, bool toDevice)
return bindPath;
}

bool DeviceUtils::isSystemDisk(const QVariantHash &devInfo)
{
bool isSystem = devInfo.value(GlobalServerDefines::DeviceProperty::kHintSystem).toBool()
|| devInfo.value(GlobalServerDefines::DeviceProperty::kConnectionBus).toString() != "usb";
if (devInfo.value(GlobalServerDefines::DeviceProperty::kOpticalDrive).toBool())
isSystem = false;
return isSystem;
}

bool DeviceUtils::isSystemDisk(const QVariantMap &devInfo)
{
QVariantHash hash;
QMapIterator<QString, QVariant> iter(devInfo);
while (iter.hasNext()) {
iter.next();
hash.insert(iter.key(), iter.value());
}
return isSystemDisk(hash);
}

bool DeviceUtils::findDlnfsPath(const QString &target, Compare func)
{
Q_ASSERT(func);
Expand Down
3 changes: 3 additions & 0 deletions src/dfm-base/base/device/deviceutils.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ class DeviceUtils
// otherwise convert the path to the mount point name
static QString bindPathTransform(const QString &path, bool toDevice);

static bool isSystemDisk(const QVariantHash &devInfo);
static bool isSystemDisk(const QVariantMap &devInfo);

private:
static bool hasMatch(const QString &txt, const QString &rex);
using Compare = std::function<bool(const QString &, const QString &)>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -644,10 +644,11 @@ QVariantMap ComputerItemWatcher::makeSidebarItem(DFMEntryFileInfoPointer info)
QString visableName;
QString reportName = "Unknown Disk";
QString subGroup = Global::Scheme::kComputer;

if (info->extraProperty(DeviceProperty::kIsLoopDevice).toBool()) {
visableKey = kItemVisiableControlKeys[1];
visableName = kItemVisiableControlNames[1];
} else if (info->extraProperty(DeviceProperty::kHintSystem).toBool()) {
} else if (DeviceUtils::isSystemDisk(info->extraProperties())) {
visableKey = kItemVisiableControlKeys[0];
visableName = kItemVisiableControlNames[0];
reportName = info->targetUrl().path() == "/" ? "System Disk" : "Data Disk";
Expand Down

0 comments on commit fc76485

Please sign in to comment.