#include <apt-pkg/strutl.h>
#include <apt-pkg/hashes.h>
+#include <algorithm>
#include <string>
#include <vector>
#include <iostream>
ItemDone();
// Change the status so that it can be dequeued
- for (pkgAcquire::Queue::QItem::owner_iterator O = Itm->Owners.begin(); O != Itm->Owners.end(); ++O)
- (*O)->Status = pkgAcquire::Item::StatIdle;
+ for (auto const &O: Itm->Owners)
+ O->Status = pkgAcquire::Item::StatIdle;
// Mark the item as done (taking care of all queues)
// and then put it in the main queue again
std::vector<Item*> const ItmOwners = Itm->Owners;
OwnerQ->ItemDone(Itm);
Itm = NULL;
+ bool errTransient;
+ {
+ std::string const failReason = LookupTag(Message, "FailReason");
+ std::string const reasons[] = { "Timeout", "ConnectionRefused",
+ "ConnectionTimedOut", "ResolveFailure", "TmpResolveFailure" };
+ errTransient = std::find(std::begin(reasons), std::end(reasons), failReason) != std::end(reasons);
+ }
+
for (pkgAcquire::Queue::QItem::owner_iterator O = ItmOwners.begin(); O != ItmOwners.end(); ++O)
{
- // set some status
- if(LookupTag(Message,"FailReason") == "Timeout" ||
- LookupTag(Message,"FailReason") == "TmpResolveFailure" ||
- LookupTag(Message,"FailReason") == "ResolveFailure" ||
- LookupTag(Message,"FailReason") == "ConnectionRefused")
+ if (errTransient)
(*O)->Status = pkgAcquire::Item::StatTransientNetworkError;
-
(*O)->Failed(Message,Config);
if (Log != 0)
if (RealFileExists(Item->Owner->DestFile))
{
- std::string SandboxUser = _config->Find("APT::Sandbox::User");
+ std::string const SandboxUser = _config->Find("APT::Sandbox::User");
ChangeOwnerAndPermissionOfFile("Item::QueueURI", Item->Owner->DestFile.c_str(),
SandboxUser.c_str(), "root", 0600);
}
for (pkgAcquire::Queue::QItem::owner_iterator O = Itm->Owners.begin(); O != Itm->Owners.end(); ++O)
{
pkgAcquire::Item const * const Owner = *O;
- if (Owner->DestFile == filename)
+ if (Owner->DestFile == filename || filename == "/dev/null")
continue;
- unlink(Owner->DestFile.c_str());
+ RemoveFile("PrepareFiles", Owner->DestFile);
if (link(filename.c_str(), Owner->DestFile.c_str()) != 0)
{
// different mounts can't happen for us as we download to lists/ by default,
else
{
for (pkgAcquire::Queue::QItem::owner_iterator O = Itm->Owners.begin(); O != Itm->Owners.end(); ++O)
- unlink((*O)->DestFile.c_str());
+ RemoveFile("PrepareFiles", (*O)->DestFile);
}
}
/*}}}*/