pkgman: auto-refresh repositories only for update/install

This commit is contained in:
Ingo Weinhold 2013-08-26 13:03:12 +02:00
parent 8b26ef6779
commit ce4f367692
4 changed files with 12 additions and 5 deletions

View File

@ -42,7 +42,7 @@ PackageManager::Repository::Repository()
status_t
PackageManager::Repository::Init(BPackageRoster& roster, BContext& context,
const char* name)
const char* name, bool refresh)
{
// get the repository config
status_t error = roster.GetRepositoryConfig(name, &fConfig);
@ -50,6 +50,9 @@ PackageManager::Repository::Init(BPackageRoster& roster, BContext& context,
return error;
// refresh
if (!refresh)
return B_OK;
BRefreshRepositoryRequest refreshRequest(context, fConfig);
error = refreshRequest.Process();
if (error != B_OK) {
@ -143,7 +146,8 @@ PackageManager::PackageManager(BPackageInstallationLocation location,
DIE(B_NO_MEMORY, "failed to create/add repository object");
const BString& name = repositoryNames.StringAt(i);
error = repository->Init(roster, fContext, name);
error = repository->Init(roster, fContext, name,
(flags & REFRESH_REPOSITORIES) != 0);
if (error != B_OK) {
WARN(error,
"failed to get config for repository \"%s\". Skipping.",

View File

@ -32,6 +32,7 @@ public:
enum {
ADD_INSTALLED_REPOSITORIES = 0x01,
ADD_REMOTE_REPOSITORIES = 0x02,
REFRESH_REPOSITORIES = 0x04,
};
public:
@ -90,7 +91,7 @@ struct PackageManager::Repository : public BSolverRepository {
Repository();
status_t Init(BPackageRoster& roster, BContext& context,
const char* name);
const char* name, bool refresh);
const BRepositoryConfig& Config() const;

View File

@ -87,7 +87,8 @@ InstallCommand::Execute(int argc, const char* const* argv)
: B_PACKAGE_INSTALLATION_LOCATION_COMMON;
PackageManager packageManager(location,
PackageManager::ADD_INSTALLED_REPOSITORIES
| PackageManager::ADD_REMOTE_REPOSITORIES);
| PackageManager::ADD_REMOTE_REPOSITORIES
| PackageManager::REFRESH_REPOSITORIES);
packageManager.Install(packages, packageCount);
return 0;

View File

@ -85,7 +85,8 @@ UpdateCommand::Execute(int argc, const char* const* argv)
: B_PACKAGE_INSTALLATION_LOCATION_COMMON;
PackageManager packageManager(location,
PackageManager::ADD_INSTALLED_REPOSITORIES
| PackageManager::ADD_REMOTE_REPOSITORIES);
| PackageManager::ADD_REMOTE_REPOSITORIES
| PackageManager::REFRESH_REPOSITORIES);
packageManager.Update(packages, packageCount);
return 0;