pkgman: Make use of BRequest::Process()
This commit is contained in:
@@ -87,18 +87,13 @@ AddRepoCommand::Execute(int argc, const char* const* argv)
|
|||||||
status_t result;
|
status_t result;
|
||||||
for (int i = 0; i < urlCount; ++i) {
|
for (int i = 0; i < urlCount; ++i) {
|
||||||
AddRepositoryRequest addRequest(context, repoURLs[i], asUserRepository);
|
AddRepositoryRequest addRequest(context, repoURLs[i], asUserRepository);
|
||||||
result = addRequest.InitCheck();
|
result = addRequest.Process(true);
|
||||||
if (result != B_OK)
|
if (result != B_OK) {
|
||||||
DIE(result, "unable to create request for adding repository");
|
if (result != B_CANCELED) {
|
||||||
result = addRequest.CreateInitialJobs();
|
DIE(result, "request for adding repository \"%s\" failed",
|
||||||
if (result != B_OK)
|
repoURLs[i]);
|
||||||
DIE(result, "unable to create necessary jobs");
|
}
|
||||||
|
return 1;
|
||||||
while (BJob* job = addRequest.PopRunnableJob()) {
|
|
||||||
result = job->Run();
|
|
||||||
delete job;
|
|
||||||
if (result == B_CANCELED)
|
|
||||||
return 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// now refresh the repo-cache of the new repository
|
// now refresh the repo-cache of the new repository
|
||||||
@@ -106,19 +101,15 @@ AddRepoCommand::Execute(int argc, const char* const* argv)
|
|||||||
BPackageRoster roster;
|
BPackageRoster roster;
|
||||||
BRepositoryConfig repoConfig;
|
BRepositoryConfig repoConfig;
|
||||||
roster.GetRepositoryConfig(repoName, &repoConfig);
|
roster.GetRepositoryConfig(repoName, &repoConfig);
|
||||||
|
|
||||||
BRefreshRepositoryRequest refreshRequest(context, repoConfig);
|
BRefreshRepositoryRequest refreshRequest(context, repoConfig);
|
||||||
result = refreshRequest.InitCheck();
|
result = refreshRequest.Process(true);
|
||||||
if (result != B_OK)
|
if (result != B_OK) {
|
||||||
DIE(result, "unable to create request for refreshing repository");
|
if (result != B_CANCELED) {
|
||||||
result = refreshRequest.CreateInitialJobs();
|
DIE(result, "request for refreshing repository \"%s\" failed",
|
||||||
if (result != B_OK)
|
repoName.String());
|
||||||
DIE(result, "unable to create necessary jobs");
|
}
|
||||||
|
return 1;
|
||||||
while (BJob* job = refreshRequest.PopRunnableJob()) {
|
|
||||||
result = job->Run();
|
|
||||||
delete job;
|
|
||||||
if (result == B_CANCELED)
|
|
||||||
return 1;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -85,18 +85,13 @@ DropRepoCommand::Execute(int argc, const char* const* argv)
|
|||||||
|
|
||||||
status_t result;
|
status_t result;
|
||||||
DropRepositoryRequest dropRequest(context, repoName);
|
DropRepositoryRequest dropRequest(context, repoName);
|
||||||
result = dropRequest.InitCheck();
|
result = dropRequest.Process(true);
|
||||||
if (result != B_OK)
|
if (result != B_OK) {
|
||||||
DIE(result, "unable to create request for dropping repository");
|
if (result != B_CANCELED) {
|
||||||
result = dropRequest.CreateInitialJobs();
|
DIE(result, "request for dropping repository \"%s\" failed",
|
||||||
if (result != B_OK)
|
repoName);
|
||||||
DIE(result, "unable to create necessary jobs");
|
}
|
||||||
|
return 1;
|
||||||
while (BJob* job = dropRequest.PopRunnableJob()) {
|
|
||||||
result = job->Run();
|
|
||||||
delete job;
|
|
||||||
if (result == B_CANCELED)
|
|
||||||
return 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
@@ -40,7 +40,6 @@ static const char* const kLongUsage =
|
|||||||
DEFINE_COMMAND(RefreshCommand, "refresh", kShortUsage, kLongUsage)
|
DEFINE_COMMAND(RefreshCommand, "refresh", kShortUsage, kLongUsage)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
RefreshCommand::Execute(int argc, const char* const* argv)
|
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;
|
const char* const* repoArgs = argv + optind;
|
||||||
int nameCount = argc - optind;
|
int nameCount = argc - optind;
|
||||||
|
|
||||||
DecisionProvider decisionProvider;
|
|
||||||
JobStateListener listener;
|
|
||||||
BContext context(decisionProvider, listener);
|
|
||||||
|
|
||||||
BStringList repositoryNames(20);
|
BStringList repositoryNames(20);
|
||||||
|
|
||||||
BPackageRoster roster;
|
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;
|
status_t result;
|
||||||
for (int i = 0; i < repositoryNames.CountStrings(); ++i) {
|
for (int i = 0; i < repositoryNames.CountStrings(); ++i) {
|
||||||
const BString& repoName = repositoryNames.StringAt(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());
|
WARN(result, "skipping repository-config '%s'", path.Path());
|
||||||
continue;
|
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()) {
|
BRefreshRepositoryRequest refreshRequest(context, repoConfig);
|
||||||
result = job->Run();
|
result = refreshRequest.Process();
|
||||||
delete job;
|
if (result != B_OK)
|
||||||
if (result != B_OK)
|
DIE(result, "request for refreshing repository failed");
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user