diff --git a/src/bin/pkgman/command_add_repo.cpp b/src/bin/pkgman/command_add_repo.cpp index b63583bf9e..798ae6a780 100644 --- a/src/bin/pkgman/command_add_repo.cpp +++ b/src/bin/pkgman/command_add_repo.cpp @@ -87,18 +87,13 @@ AddRepoCommand::Execute(int argc, const char* const* argv) status_t result; for (int i = 0; i < urlCount; ++i) { AddRepositoryRequest addRequest(context, repoURLs[i], asUserRepository); - result = addRequest.InitCheck(); - if (result != B_OK) - DIE(result, "unable to create request for adding repository"); - result = addRequest.CreateInitialJobs(); - if (result != B_OK) - DIE(result, "unable to create necessary jobs"); - - while (BJob* job = addRequest.PopRunnableJob()) { - result = job->Run(); - delete job; - if (result == B_CANCELED) - return 1; + result = addRequest.Process(true); + if (result != B_OK) { + if (result != B_CANCELED) { + DIE(result, "request for adding repository \"%s\" failed", + repoURLs[i]); + } + return 1; } // now refresh the repo-cache of the new repository @@ -106,19 +101,15 @@ AddRepoCommand::Execute(int argc, const char* const* argv) BPackageRoster roster; BRepositoryConfig repoConfig; roster.GetRepositoryConfig(repoName, &repoConfig); + BRefreshRepositoryRequest refreshRequest(context, repoConfig); - result = refreshRequest.InitCheck(); - if (result != B_OK) - DIE(result, "unable to create request for refreshing repository"); - result = refreshRequest.CreateInitialJobs(); - if (result != B_OK) - DIE(result, "unable to create necessary jobs"); - - while (BJob* job = refreshRequest.PopRunnableJob()) { - result = job->Run(); - delete job; - if (result == B_CANCELED) - return 1; + result = refreshRequest.Process(true); + if (result != B_OK) { + if (result != B_CANCELED) { + DIE(result, "request for refreshing repository \"%s\" failed", + repoName.String()); + } + return 1; } } diff --git a/src/bin/pkgman/command_drop_repo.cpp b/src/bin/pkgman/command_drop_repo.cpp index e026757b8c..0703fb1011 100644 --- a/src/bin/pkgman/command_drop_repo.cpp +++ b/src/bin/pkgman/command_drop_repo.cpp @@ -85,18 +85,13 @@ DropRepoCommand::Execute(int argc, const char* const* argv) status_t result; DropRepositoryRequest dropRequest(context, repoName); - result = dropRequest.InitCheck(); - if (result != B_OK) - DIE(result, "unable to create request for dropping repository"); - result = dropRequest.CreateInitialJobs(); - if (result != B_OK) - DIE(result, "unable to create necessary jobs"); - - while (BJob* job = dropRequest.PopRunnableJob()) { - result = job->Run(); - delete job; - if (result == B_CANCELED) - return 1; + result = dropRequest.Process(true); + if (result != B_OK) { + if (result != B_CANCELED) { + DIE(result, "request for dropping repository \"%s\" failed", + repoName); + } + return 1; } return 0; diff --git a/src/bin/pkgman/command_refresh.cpp b/src/bin/pkgman/command_refresh.cpp index 50764c99c6..6023edca6a 100644 --- a/src/bin/pkgman/command_refresh.cpp +++ b/src/bin/pkgman/command_refresh.cpp @@ -40,7 +40,6 @@ static const char* const kLongUsage = DEFINE_COMMAND(RefreshCommand, "refresh", kShortUsage, kLongUsage) - int RefreshCommand::Execute(int argc, const char* const* argv) { @@ -70,10 +69,6 @@ RefreshCommand::Execute(int argc, const char* const* argv) const char* const* repoArgs = argv + optind; int nameCount = argc - optind; - DecisionProvider decisionProvider; - JobStateListener listener; - BContext context(decisionProvider, listener); - BStringList repositoryNames(20); BPackageRoster roster; @@ -88,6 +83,10 @@ RefreshCommand::Execute(int argc, const char* const* argv) } } + DecisionProvider decisionProvider; + JobStateListener listener; + BContext context(decisionProvider, listener); + status_t result; for (int i = 0; i < repositoryNames.CountStrings(); ++i) { const BString& repoName = repositoryNames.StringAt(i); @@ -99,20 +98,11 @@ RefreshCommand::Execute(int argc, const char* const* argv) WARN(result, "skipping repository-config '%s'", path.Path()); continue; } - BRefreshRepositoryRequest refreshRequest(context, repoConfig); - result = refreshRequest.InitCheck(); - if (result != B_OK) - DIE(result, "unable to create request for refreshing repository"); - result = refreshRequest.CreateInitialJobs(); - if (result != B_OK) - DIE(result, "unable to create necessary jobs"); - while (BJob* job = refreshRequest.PopRunnableJob()) { - result = job->Run(); - delete job; - if (result != B_OK) - return 1; - } + BRefreshRepositoryRequest refreshRequest(context, repoConfig); + result = refreshRequest.Process(); + if (result != B_OK) + DIE(result, "request for refreshing repository failed"); } return 0;