summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Kalnischkies <david@kalnischkies.de>2016-03-17 12:10:37 +0100
committerDavid Kalnischkies <david@kalnischkies.de>2016-03-19 09:48:44 +0100
commitd32223495b4b6e077c8c4db54a0dd972c7a1548a (patch)
tree7ca3780fdde72077572c36385c36ed7e0947cb57
parent28b2efcb190edd97b802ac9055eaf417f141f724 (diff)
refactor loading of previous release file
There is really no need to have the same code three times. Git-Dch: Ignore
-rw-r--r--apt-pkg/acquire-item.cc95
1 files changed, 29 insertions, 66 deletions
diff --git a/apt-pkg/acquire-item.cc b/apt-pkg/acquire-item.cc
index 2180a5a41..1b817df71 100644
--- a/apt-pkg/acquire-item.cc
+++ b/apt-pkg/acquire-item.cc
@@ -802,6 +802,32 @@ HashStringList pkgAcqTransactionItem::GetExpectedHashesFor(std::string const &Me
}
/*}}}*/
+static void LoadLastMetaIndexParser(pkgAcqMetaClearSig * const TransactionManager, std::string const &FinalRelease, std::string const &FinalInRelease)/*{{{*/
+{
+ if (TransactionManager->IMSHit == true)
+ return;
+ if (RealFileExists(FinalInRelease) || RealFileExists(FinalRelease))
+ {
+ TransactionManager->LastMetaIndexParser = TransactionManager->MetaIndexParser->UnloadedClone();
+ if (TransactionManager->LastMetaIndexParser != NULL)
+ {
+ _error->PushToStack();
+ if (RealFileExists(FinalInRelease))
+ TransactionManager->LastMetaIndexParser->Load(FinalInRelease, NULL);
+ else
+ TransactionManager->LastMetaIndexParser->Load(FinalRelease, NULL);
+ // its unlikely to happen, but if what we have is bad ignore it
+ if (_error->PendingError())
+ {
+ delete TransactionManager->LastMetaIndexParser;
+ TransactionManager->LastMetaIndexParser = NULL;
+ }
+ _error->RevertToStack();
+ }
+ }
+}
+ /*}}}*/
+
// AcqMetaBase - Constructor /*{{{*/
pkgAcqMetaBase::pkgAcqMetaBase(pkgAcquire * const Owner,
pkgAcqMetaClearSig * const TransactionManager,
@@ -1014,25 +1040,7 @@ bool pkgAcqMetaBase::CheckAuthDone(string const &Message) /*{{{*/
FinalInRelease = FinalFile.substr(0, FinalFile.length() - strlen("Release")) + "InRelease";
FinalRelease = FinalFile;
}
- if (RealFileExists(FinalInRelease) || RealFileExists(FinalRelease))
- {
- TransactionManager->LastMetaIndexParser = TransactionManager->MetaIndexParser->UnloadedClone();
- if (TransactionManager->LastMetaIndexParser != NULL)
- {
- _error->PushToStack();
- if (RealFileExists(FinalInRelease))
- TransactionManager->LastMetaIndexParser->Load(FinalInRelease, NULL);
- else
- TransactionManager->LastMetaIndexParser->Load(FinalRelease, NULL);
- // its unlikely to happen, but if what we have is bad ignore it
- if (_error->PendingError())
- {
- delete TransactionManager->LastMetaIndexParser;
- TransactionManager->LastMetaIndexParser = NULL;
- }
- _error->RevertToStack();
- }
- }
+ LoadLastMetaIndexParser(TransactionManager, FinalRelease, FinalInRelease);
}
if (TransactionManager->MetaIndexParser->Load(DestFile, &ErrorText) == false)
@@ -1428,30 +1436,7 @@ void pkgAcqMetaClearSig::Failed(string const &Message,pkgAcquire::MethodConfig c
string const FinalInRelease = GetFinalFilename();
Rename(DestFile, PartialRelease);
TransactionManager->TransactionStageCopy(this, PartialRelease, FinalRelease);
-
- if (RealFileExists(FinalReleasegpg) || RealFileExists(FinalInRelease))
- {
- // open the last Release if we have it
- if (TransactionManager->IMSHit == false)
- {
- TransactionManager->LastMetaIndexParser = TransactionManager->MetaIndexParser->UnloadedClone();
- if (TransactionManager->LastMetaIndexParser != NULL)
- {
- _error->PushToStack();
- if (RealFileExists(FinalInRelease))
- TransactionManager->LastMetaIndexParser->Load(FinalInRelease, NULL);
- else
- TransactionManager->LastMetaIndexParser->Load(FinalRelease, NULL);
- // its unlikely to happen, but if what we have is bad ignore it
- if (_error->PendingError())
- {
- delete TransactionManager->LastMetaIndexParser;
- TransactionManager->LastMetaIndexParser = NULL;
- }
- _error->RevertToStack();
- }
- }
- }
+ LoadLastMetaIndexParser(TransactionManager, FinalRelease, FinalInRelease);
// we parse the indexes here because at this point the user wanted
// a repository that may potentially harm him
@@ -1667,29 +1652,7 @@ void pkgAcqMetaSig::Failed(string const &Message,pkgAcquire::MethodConfig const
// only allow going further if the user explicitly wants it
if (AllowInsecureRepositories(_("The repository '%s' is not signed."), MetaIndex->Target.Description, TransactionManager->MetaIndexParser, TransactionManager, this) == true)
{
- if (RealFileExists(FinalReleasegpg) || RealFileExists(FinalInRelease))
- {
- // open the last Release if we have it
- if (TransactionManager->IMSHit == false)
- {
- TransactionManager->LastMetaIndexParser = TransactionManager->MetaIndexParser->UnloadedClone();
- if (TransactionManager->LastMetaIndexParser != NULL)
- {
- _error->PushToStack();
- if (RealFileExists(FinalInRelease))
- TransactionManager->LastMetaIndexParser->Load(FinalInRelease, NULL);
- else
- TransactionManager->LastMetaIndexParser->Load(FinalRelease, NULL);
- // its unlikely to happen, but if what we have is bad ignore it
- if (_error->PendingError())
- {
- delete TransactionManager->LastMetaIndexParser;
- TransactionManager->LastMetaIndexParser = NULL;
- }
- _error->RevertToStack();
- }
- }
- }
+ LoadLastMetaIndexParser(TransactionManager, FinalRelease, FinalInRelease);
// we parse the indexes here because at this point the user wanted
// a repository that may potentially harm him