[netinstall] Avoid duplicate operations

- Since operations are added each time you leave this page,
   the existing operations (from a previous visit) need to be
   cleaned up. With the old setup of only **one** possible
   set of operations, this wasn't a problem. Now, merging
   in operations is necessary. Implement that by looking for
   the *source* property in an operation.

FIXES #1303
This commit is contained in:
Adriaan de Groot 2020-02-18 14:46:00 +01:00
parent 74169c166a
commit 5f1bd4396e

View File

@ -125,6 +125,19 @@ NetInstallViewStep::onLeave()
QVariantList packageOperations = gs->contains( PACKAGEOP ) ? gs->value( PACKAGEOP ).toList() : QVariantList();
cDebug() << Logger::SubEntry << "Existing package operations length" << packageOperations.length();
// Clear out existing operations for this module, going backwards:
// Sometimes we remove an item, and we don't want the index to
// fall off the end of the list.
for ( int index = packageOperations.length() - 1; 0 <= index ; index-- )
{
const QVariantMap op = packageOperations.at(index).toMap();
if ( op.contains( "source" ) && op.value( "source" ).toString() == moduleInstanceKey().toString() )
{
cDebug() << Logger::SubEntry << "Removing existing operations for" << moduleInstanceKey();
packageOperations.removeAt( index );
}
}
// This netinstall module may add two sub-steps to the packageOperations,
// one for installing and one for try-installing.
QVariantList installPackages;