Getting lsblk kname in the cases where the model name isn't available
Summary: lsblk command does not return model name as output in some specific cases, specially when you have a micro SD in your computer (perhaps it should happen with a normal SD card as well, but I haven't tested it). So I included a verification in SfdiskBackend::scanDevice to check for kname in lsblk and use it as the name in these cases. Reviewers: stikonas Reviewed By: stikonas Tags: #kde_partition_manager Differential Revision: https://phabricator.kde.org/D16577
This commit is contained in:
parent
b22be9ad9a
commit
0e4fca8de6
|
@ -169,12 +169,23 @@ Device* SfdiskBackend::scanDevice(const QString& deviceNode)
|
|||
|
||||
if ( d == nullptr && modelCommand.run(-1) && modelCommand.exitCode() == 0 )
|
||||
{
|
||||
QString modelName = modelCommand.output();
|
||||
modelName = modelName.left(modelName.length() - 1);
|
||||
QString name = modelCommand.output();
|
||||
name = name.left(name.length() - 1);
|
||||
|
||||
Log(Log::Level::information) << xi18nc("@info:status", "Device found: %1", modelName);
|
||||
if (name.trimmed().isEmpty()) {
|
||||
// Get 'lsblk --output kname' in the cases where the model name is not available.
|
||||
// As lsblk doesn't have an option to include a separator in its output, it is
|
||||
// necessary to run it again getting only the kname as output.
|
||||
ExternalCommand kname(QStringLiteral("lsblk"), {QStringLiteral("--nodeps"), QStringLiteral("--noheadings"), QStringLiteral("--output"), QStringLiteral("kname"),
|
||||
deviceNode});
|
||||
|
||||
d = new DiskDevice(modelName, deviceNode, 255, 63, deviceSize / logicalSectorSize / 255 / 63, logicalSectorSize);
|
||||
if (kname.run(-1) && kname.exitCode() == 0)
|
||||
name = kname.output();
|
||||
}
|
||||
|
||||
Log(Log::Level::information) << xi18nc("@info:status", "Device found: %1", name);
|
||||
|
||||
d = new DiskDevice(name, deviceNode, 255, 63, deviceSize / logicalSectorSize / 255 / 63, logicalSectorSize);
|
||||
}
|
||||
|
||||
if ( d )
|
||||
|
|
Loading…
Reference in New Issue