pkgman install: Simplify transaction creation

This commit is contained in:
Ingo Weinhold
2013-04-21 10:36:19 +02:00
parent 2f028e9a2d
commit 7466fa2d49
+3 -13
View File
@@ -357,16 +357,8 @@ InstallCommand::Execute(int argc, const char* const* argv)
DIE(error, "failed to create transaction"); DIE(error, "failed to create transaction");
// download the new packages and prepare the transaction // download the new packages and prepare the transaction
for (int32 i = 0; const BSolverResultElement* element = result.ElementAt(i); for (int32 i = 0; BSolverPackage* package = packagesToActivate.ItemAt(i);
i++) { i++) {
BSolverPackage* package = element->Package();
switch (element->Type()) {
case BSolverResultElement::B_TYPE_INSTALL:
{
if (installedRepositories.HasItem(package->Repository()))
continue;
// get package URL and target entry // get package URL and target entry
Repository* repository Repository* repository
= static_cast<Repository*>(package->Repository()); = static_cast<Repository*>(package->Repository());
@@ -394,18 +386,16 @@ InstallCommand::Execute(int argc, const char* const* argv)
DIE(B_NO_MEMORY, DIE(B_NO_MEMORY,
"failed to add package to activate to transaction"); "failed to add package to activate to transaction");
} }
break;
} }
case BSolverResultElement::B_TYPE_UNINSTALL: for (int32 i = 0; BSolverPackage* package = packagesToDeactivate.ItemAt(i);
i++) {
// add package to transaction // add package to transaction
if (!transaction.AddPackageToDeactivate( if (!transaction.AddPackageToDeactivate(
package->Info().CanonicalFileName())) { package->Info().CanonicalFileName())) {
DIE(B_NO_MEMORY, DIE(B_NO_MEMORY,
"failed to add package to deactivate to transaction"); "failed to add package to deactivate to transaction");
} }
break;
}
} }
// commit the transaction // commit the transaction