BPackageManager: Make BCommitTransactionResult available
* BFatalErrorException: Add commitTransactionResult property and respective constructor. In case committing the transaction failed, BPackageManager throws a BFatalErrorException with the result. * BFatalErrorException::UserInteractionHandler: Pass BCommitTransactionResult to ProgressTransactionCommitted().
This commit is contained in:
parent
0de3219e33
commit
eee422752c
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013, Haiku, Inc. All Rights Reserved.
|
||||
* Copyright 2013-2014, Haiku, Inc. All Rights Reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors:
|
||||
@ -9,6 +9,7 @@
|
||||
#define _PACKAGE__MANAGER__PRIVATE__EXCEPTIONS_H_
|
||||
|
||||
|
||||
#include <package/CommitTransactionResult.h>
|
||||
#include <package/Context.h>
|
||||
|
||||
|
||||
@ -38,6 +39,8 @@ public:
|
||||
BFatalErrorException(const char* format, ...);
|
||||
BFatalErrorException(status_t error,
|
||||
const char* format, ...);
|
||||
BFatalErrorException(
|
||||
const BCommitTransactionResult& result);
|
||||
|
||||
const BString& Details() const
|
||||
{ return fDetails; }
|
||||
@ -46,9 +49,16 @@ public:
|
||||
status_t Error() const
|
||||
{ return fError; }
|
||||
|
||||
bool HasCommitTransactionFailed() const
|
||||
{ return fCommitTransactionFailed; }
|
||||
const BCommitTransactionResult& CommitTransactionResult() const
|
||||
{ return fCommitTransactionResult; }
|
||||
|
||||
private:
|
||||
BString fDetails;
|
||||
status_t fError;
|
||||
BCommitTransactionResult fCommitTransactionResult;
|
||||
bool fCommitTransactionFailed;
|
||||
};
|
||||
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013, Haiku, Inc. All Rights Reserved.
|
||||
* Copyright 2013-2014, Haiku, Inc. All Rights Reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors:
|
||||
@ -26,6 +26,10 @@
|
||||
|
||||
namespace BPackageKit {
|
||||
|
||||
|
||||
class BCommitTransactionResult;
|
||||
|
||||
|
||||
namespace BManager {
|
||||
|
||||
namespace BPrivate {
|
||||
@ -281,7 +285,7 @@ public:
|
||||
InstalledRepository& repository);
|
||||
virtual void ProgressTransactionCommitted(
|
||||
InstalledRepository& repository,
|
||||
const char* transactionDirectoryName);
|
||||
const BCommitTransactionResult& result);
|
||||
virtual void ProgressApplyingChangesDone(
|
||||
InstalledRepository& repository);
|
||||
};
|
||||
|
@ -492,7 +492,7 @@ PackageManager::ProgressStartApplyingChanges(InstalledRepository& repository)
|
||||
|
||||
void
|
||||
PackageManager::ProgressTransactionCommitted(InstalledRepository& repository,
|
||||
const char* transactionDirectoryName)
|
||||
const BCommitTransactionResult& result)
|
||||
{
|
||||
// TODO: implement
|
||||
}
|
||||
|
@ -29,6 +29,7 @@ class ProblemWindow;
|
||||
class ResultWindow;
|
||||
|
||||
|
||||
using BPackageKit::BCommitTransactionResult;
|
||||
using BPackageKit::BContext;
|
||||
using BPackageKit::BPackageInstallationLocation;
|
||||
using BPackageKit::BRepositoryConfig;
|
||||
@ -107,7 +108,7 @@ private:
|
||||
InstalledRepository& repository);
|
||||
virtual void ProgressTransactionCommitted(
|
||||
InstalledRepository& repository,
|
||||
const char* transactionDirectoryName);
|
||||
const BCommitTransactionResult& result);
|
||||
virtual void ProgressApplyingChangesDone(
|
||||
InstalledRepository& repository);
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013, Haiku, Inc. All Rights Reserved.
|
||||
* Copyright 2013-2014, Haiku, Inc. All Rights Reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors:
|
||||
@ -10,6 +10,7 @@
|
||||
|
||||
#include "PackageManager.h"
|
||||
|
||||
#include <package/CommitTransactionResult.h>
|
||||
#include <package/DownloadFileRequest.h>
|
||||
#include <package/RefreshRepositoryRequest.h>
|
||||
#include <package/solver/SolverPackage.h>
|
||||
@ -222,10 +223,10 @@ PackageManager::ProgressStartApplyingChanges(InstalledRepository& repository)
|
||||
|
||||
void
|
||||
PackageManager::ProgressTransactionCommitted(InstalledRepository& repository,
|
||||
const char* transactionDirectoryName)
|
||||
const BCommitTransactionResult& result)
|
||||
{
|
||||
printf("[%s] Changes applied. Old activation state backed up in \"%s\"\n",
|
||||
repository.Name().String(), transactionDirectoryName);
|
||||
repository.Name().String(), result.OldStateDirectory().String());
|
||||
printf("[%s] Cleaning up ...\n", repository.Name().String());
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013, Haiku, Inc. All Rights Reserved.
|
||||
* Copyright 2013-2014, Haiku, Inc. All Rights Reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors:
|
||||
@ -58,7 +58,7 @@ private:
|
||||
InstalledRepository& repository);
|
||||
virtual void ProgressTransactionCommitted(
|
||||
InstalledRepository& repository,
|
||||
const char* transactionDirectoryName);
|
||||
const BCommitTransactionResult& result);
|
||||
virtual void ProgressApplyingChangesDone(
|
||||
InstalledRepository& repository);
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013, Ingo Weinhold, ingo_weinhold@gmx.de.
|
||||
* Copyright 2013-2014, Ingo Weinhold, ingo_weinhold@gmx.de.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
|
||||
@ -40,7 +40,9 @@ BFatalErrorException::BFatalErrorException()
|
||||
:
|
||||
BException(),
|
||||
fDetails(),
|
||||
fError(B_OK)
|
||||
fError(B_OK),
|
||||
fCommitTransactionResult(),
|
||||
fCommitTransactionFailed(false)
|
||||
{
|
||||
}
|
||||
|
||||
@ -49,7 +51,9 @@ BFatalErrorException::BFatalErrorException(const char* format, ...)
|
||||
:
|
||||
BException(),
|
||||
fDetails(),
|
||||
fError(B_OK)
|
||||
fError(B_OK),
|
||||
fCommitTransactionResult(),
|
||||
fCommitTransactionFailed(false)
|
||||
{
|
||||
va_list args;
|
||||
va_start(args, format);
|
||||
@ -63,7 +67,9 @@ BFatalErrorException::BFatalErrorException(status_t error, const char* format,
|
||||
:
|
||||
BException(),
|
||||
fDetails(),
|
||||
fError(error)
|
||||
fError(error),
|
||||
fCommitTransactionResult(),
|
||||
fCommitTransactionFailed(false)
|
||||
{
|
||||
va_list args;
|
||||
va_start(args, format);
|
||||
@ -72,6 +78,20 @@ BFatalErrorException::BFatalErrorException(status_t error, const char* format,
|
||||
}
|
||||
|
||||
|
||||
BFatalErrorException::BFatalErrorException(
|
||||
const BCommitTransactionResult& result)
|
||||
:
|
||||
BException(),
|
||||
fDetails(),
|
||||
fError(B_OK),
|
||||
fCommitTransactionResult(result),
|
||||
fCommitTransactionFailed(true)
|
||||
{
|
||||
fMessage.SetToFormat("failed to commit transaction: %s",
|
||||
result.FullErrorMessage().String());
|
||||
}
|
||||
|
||||
|
||||
BFatalErrorException&
|
||||
BFatalErrorException::SetDetails(const BString& details)
|
||||
{
|
||||
|
@ -582,13 +582,11 @@ BPackageManager::_CommitPackageChanges(Transaction& transaction)
|
||||
transactionResult);
|
||||
if (error != B_OK)
|
||||
DIE(error, "failed to commit transaction");
|
||||
if (transactionResult.Error() != B_TRANSACTION_OK) {
|
||||
DIE("failed to commit transaction: %s",
|
||||
transactionResult.FullErrorMessage().String());
|
||||
}
|
||||
if (transactionResult.Error() != B_TRANSACTION_OK)
|
||||
DIE(transactionResult);
|
||||
|
||||
fUserInteractionHandler->ProgressTransactionCommitted(
|
||||
installationRepository, transactionResult.OldStateDirectory());
|
||||
installationRepository, transactionResult);
|
||||
|
||||
BEntry transactionDirectoryEntry;
|
||||
if ((error = transaction.TransactionDirectory()
|
||||
@ -1014,7 +1012,7 @@ BPackageManager::UserInteractionHandler::ProgressStartApplyingChanges(
|
||||
|
||||
void
|
||||
BPackageManager::UserInteractionHandler::ProgressTransactionCommitted(
|
||||
InstalledRepository& repository, const char* transactionDirectoryName)
|
||||
InstalledRepository& repository, const BCommitTransactionResult& result)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -351,7 +351,7 @@ PackageManager::ProgressStartApplyingChanges(InstalledRepository& repository)
|
||||
|
||||
void
|
||||
PackageManager::ProgressTransactionCommitted(InstalledRepository& repository,
|
||||
const char* transactionDirectoryName)
|
||||
const BCommitTransactionResult& result)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -77,7 +77,7 @@ private:
|
||||
InstalledRepository& repository);
|
||||
virtual void ProgressTransactionCommitted(
|
||||
InstalledRepository& repository,
|
||||
const char* transactionDirectoryName);
|
||||
const BCommitTransactionResult& result);
|
||||
virtual void ProgressApplyingChangesDone(
|
||||
InstalledRepository& repository);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user