From 2b1e516ec13eca0e75768a3bb75319b944a2e552 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABl=20PORTAY?= Date: Fri, 15 May 2020 17:03:51 -0400 Subject: [PATCH] [partition] Strip extra file after the at sign - os-proper may return an extra file after the device: /dev/sda1:Ubuntu 19.10 (19.10):Ubuntu:linux /dev/sdb1@/EFI/Microsoft/Boot/bootmgfw.efi:Windows Boot Manager:Windows:efi --- src/modules/partition/core/OsproberEntry.h | 1 + src/modules/partition/core/PartUtils.cpp | 12 ++++++++++-- src/modules/partition/gui/ReplaceWidget.cpp | 2 +- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/modules/partition/core/OsproberEntry.h b/src/modules/partition/core/OsproberEntry.h index a358e4285..86b7691b8 100644 --- a/src/modules/partition/core/OsproberEntry.h +++ b/src/modules/partition/core/OsproberEntry.h @@ -41,6 +41,7 @@ struct OsproberEntry { QString prettyName; QString path; + QString file; QString uuid; bool canBeResized; QStringList line; diff --git a/src/modules/partition/core/PartUtils.cpp b/src/modules/partition/core/PartUtils.cpp index 36b5cefe2..e6c1a520d 100644 --- a/src/modules/partition/core/PartUtils.cpp +++ b/src/modules/partition/core/PartUtils.cpp @@ -393,17 +393,25 @@ runOsprober( DeviceModel* dm ) prettyName = lineColumns.value( 2 ).simplified(); } - QString path = lineColumns.value( 0 ).simplified(); + QString file, path = lineColumns.value( 0 ).simplified(); if ( !path.startsWith( "/dev/" ) ) //basic sanity check { continue; } + // strip extra file after device: /dev/name@/path/to/file + int index = path.indexOf( '@' ); + if ( index != -1 ) + { + file = path.right( path.length() - index - 1 ); + path = path.left( index ); + } + FstabEntryList fstabEntries = lookForFstabEntries( path ); QString homePath = findPartitionPathForMountPoint( fstabEntries, "/home" ); osproberEntries.append( - { prettyName, path, QString(), canBeResized( dm, path ), lineColumns, fstabEntries, homePath } ); + { prettyName, path, file, QString(), canBeResized( dm, path ), lineColumns, fstabEntries, homePath } ); osproberCleanLines.append( line ); } } diff --git a/src/modules/partition/gui/ReplaceWidget.cpp b/src/modules/partition/gui/ReplaceWidget.cpp index a316d98b2..cc2b9d4ec 100644 --- a/src/modules/partition/gui/ReplaceWidget.cpp +++ b/src/modules/partition/gui/ReplaceWidget.cpp @@ -177,7 +177,7 @@ ReplaceWidget::onPartitionSelected() QString fsNameForUser = userVisibleFS( partition->fileSystem() ); QString prettyName = tr( "Data partition (%1)" ).arg( fsNameForUser ); - for ( const QString& line : osproberLines ) + for ( const auto& line : osproberLines ) { QStringList lineColumns = line.split( ':' );