chroot support in package kit: style fixes

- Catching an exception in the normal flow is not a good thing, instead,
  test before calling the function (I've been doing too much python
  lately)
- Avoid using uninitialized nodeRef if there is no system root and also
  no specified root in the message.

Thanks to Ingo or the code review.
This commit is contained in:
Adrien Destugues
2016-08-21 10:38:23 +02:00
parent e0c25f9892
commit a22f114f7d
2 changed files with 8 additions and 5 deletions
+6 -4
View File
@@ -110,11 +110,13 @@ BPackageManager::Init(uint32 flags)
// well. But we can easily filter those out.
_AddInstalledRepository(fSystemRepository);
try {
if (!fSystemRepository->IsInstalled())
if (!fSystemRepository->IsInstalled())
{
// Only add the home repository if the directory exists
BPath path;
status_t error = find_directory(B_USER_PACKAGES_DIRECTORY, &path);
if (error == B_OK && BEntry(path.Path()).Exists())
_AddInstalledRepository(fHomeRepository);
} catch(BFatalErrorException& exception) {
// No home repository found. This is ok for haikuporter chroots.
}
}
+2 -1
View File
@@ -93,8 +93,9 @@ PackageDaemon::MessageReceived(BMessage* message)
if (fSystemRoot != NULL && (error != B_OK
|| fSystemRoot->NodeRef() == nodeRef))
{
fSystemRoot->HandleRequest(DetachCurrentMessage());
else {
} else if (error == B_OK) {
Root* root = _FindRoot(nodeRef);
if (root != NULL) {
root->HandleRequest(DetachCurrentMessage());