Package Kit: Always allocate local repository
Consequently always register it with the solver in Init(). This solves the problem that it made a difference at which time Init() is called. Init() is called at the beginning of Install() and Uninstall(), but HaikuDepot was calling it before that for other reasons. A second call to Init() will exit early. If local package files were added to the PackageManager instance, the local repository was created lazily, but because Init() did not run a second time, the local repository was not registered with the solver. Now it already is, since it is no longer created on demand, but always.
This commit is contained in:
@@ -59,7 +59,7 @@ BPackageManager::BPackageManager(BPackageInstallationLocation location,
|
|||||||
B_PACKAGE_INSTALLATION_LOCATION_HOME, -3)),
|
B_PACKAGE_INSTALLATION_LOCATION_HOME, -3)),
|
||||||
fInstalledRepositories(10),
|
fInstalledRepositories(10),
|
||||||
fOtherRepositories(10, true),
|
fOtherRepositories(10, true),
|
||||||
fLocalRepository(NULL),
|
fLocalRepository(new (std::nothrow) MiscLocalRepository),
|
||||||
fTransactions(5, true),
|
fTransactions(5, true),
|
||||||
fInstallationInterface(installationInterface),
|
fInstallationInterface(installationInterface),
|
||||||
fUserInteractionHandler(userInteractionHandler)
|
fUserInteractionHandler(userInteractionHandler)
|
||||||
@@ -87,11 +87,12 @@ BPackageManager::Init(uint32 flags)
|
|||||||
if (error != B_OK)
|
if (error != B_OK)
|
||||||
DIE(error, "failed to create solver");
|
DIE(error, "failed to create solver");
|
||||||
|
|
||||||
if (fSystemRepository == NULL || fHomeRepository == NULL)
|
if (fSystemRepository == NULL || fHomeRepository == NULL
|
||||||
|
|| fLocalRepository == NULL) {
|
||||||
throw std::bad_alloc();
|
throw std::bad_alloc();
|
||||||
|
}
|
||||||
|
|
||||||
if (fLocalRepository != NULL)
|
BRepositoryBuilder(*fLocalRepository).AddToSolver(fSolver, false);
|
||||||
BRepositoryBuilder(*fLocalRepository).AddToSolver(fSolver, false);
|
|
||||||
|
|
||||||
// add installation location repositories
|
// add installation location repositories
|
||||||
if ((flags & B_ADD_INSTALLED_REPOSITORIES) != 0) {
|
if ((flags & B_ADD_INSTALLED_REPOSITORIES) != 0) {
|
||||||
@@ -763,10 +764,8 @@ BPackageManager::_IsLocalPackage(const char* fileName)
|
|||||||
BSolverPackage*
|
BSolverPackage*
|
||||||
BPackageManager::_AddLocalPackage(const char* fileName)
|
BPackageManager::_AddLocalPackage(const char* fileName)
|
||||||
{
|
{
|
||||||
// We need a local repository.
|
|
||||||
if (fLocalRepository == NULL)
|
if (fLocalRepository == NULL)
|
||||||
fLocalRepository = new MiscLocalRepository;
|
throw std::bad_alloc();
|
||||||
|
|
||||||
return fLocalRepository->AddLocalPackage(fileName);
|
return fLocalRepository->AddLocalPackage(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user