mirror of
https://github.com/parchlinux/calamares.git
synced 2025-06-25 08:28:22 -04:00
Keys are not necessarily unique, so use a QList< QPair > instead.
This commit is contained in:
parent
20a8b222c6
commit
642b4be1f2
1 changed files with 9 additions and 8 deletions
|
@ -43,7 +43,7 @@ Calamares::JobResult
|
||||||
ClearTempMountsJob::exec()
|
ClearTempMountsJob::exec()
|
||||||
{
|
{
|
||||||
// Fetch a list of current mounts to Calamares temporary directories.
|
// Fetch a list of current mounts to Calamares temporary directories.
|
||||||
QMap< QString, QString > lst;
|
QList< QPair < QString, QString > > lst;
|
||||||
QFile mtab( "/etc/mtab" );
|
QFile mtab( "/etc/mtab" );
|
||||||
if ( !mtab.open( QFile::ReadOnly | QFile::Text ) )
|
if ( !mtab.open( QFile::ReadOnly | QFile::Text ) )
|
||||||
return Calamares::JobResult::error( tr( "Cannot get list of temporary mounts." ) );
|
return Calamares::JobResult::error( tr( "Cannot get list of temporary mounts." ) );
|
||||||
|
@ -59,21 +59,22 @@ ClearTempMountsJob::exec()
|
||||||
if ( mountPoint.startsWith( "/tmp/calamares-" ) )
|
if ( mountPoint.startsWith( "/tmp/calamares-" ) )
|
||||||
{
|
{
|
||||||
cDebug() << "INSERTING pair (device, mountPoint)" << device << mountPoint;
|
cDebug() << "INSERTING pair (device, mountPoint)" << device << mountPoint;
|
||||||
lst.insert( device, mountPoint );
|
lst.append( qMakePair( device, mountPoint ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList keys = lst.keys();
|
qSort( lst.begin(), lst.end(), []( const QPair< QString, QString >& a,
|
||||||
keys.sort();
|
const QPair< QString, QString >& b ) -> bool
|
||||||
|
{
|
||||||
cDebug() << "Sorted keys:\n" << keys;
|
return a.first > b.first;
|
||||||
|
} );
|
||||||
|
|
||||||
QStringList goodNews;
|
QStringList goodNews;
|
||||||
QProcess process;
|
QProcess process;
|
||||||
|
|
||||||
for ( int i = keys.length() - 1; i >= 0; --i )
|
foreach ( auto line, lst )
|
||||||
{
|
{
|
||||||
QString partPath = lst.value( keys[ i ] );
|
QString partPath = line.second;
|
||||||
cDebug() << "Will try to umount path" << partPath;
|
cDebug() << "Will try to umount path" << partPath;
|
||||||
process.start( "umount", { "-lv", partPath } );
|
process.start( "umount", { "-lv", partPath } );
|
||||||
process.waitForFinished();
|
process.waitForFinished();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue