diff options
Diffstat (limited to 'apt-pkg/acquire.cc')
-rw-r--r-- | apt-pkg/acquire.cc | 50 |
1 files changed, 13 insertions, 37 deletions
diff --git a/apt-pkg/acquire.cc b/apt-pkg/acquire.cc index 541785b03..8bb72d549 100644 --- a/apt-pkg/acquire.cc +++ b/apt-pkg/acquire.cc @@ -127,25 +127,6 @@ static bool SetupAPTPartialDirectory(std::string const &grand, std::string const return true; } -bool pkgAcquire::Setup(pkgAcquireStatus *Progress, string const &Lock) -{ - Log = Progress; - if (Lock.empty()) - { - string const listDir = _config->FindDir("Dir::State::lists"); - if (SetupAPTPartialDirectory(_config->FindDir("Dir::State"), listDir, "partial", 0700) == false) - return _error->Errno("Acquire", _("List directory %s is missing."), (listDir + "partial").c_str()); - if (SetupAPTPartialDirectory(_config->FindDir("Dir::State"), listDir, "auxfiles", 0755) == false) - { - // not being able to create lists/auxfiles isn't critical as we will use a tmpdir then - } - string const archivesDir = _config->FindDir("Dir::Cache::Archives"); - if (SetupAPTPartialDirectory(_config->FindDir("Dir::Cache"), archivesDir, "partial", 0700) == false) - return _error->Errno("Acquire", _("Archives directory %s is missing."), (archivesDir + "partial").c_str()); - return true; - } - return GetLock(Lock); -} bool pkgAcquire::GetLock(std::string const &Lock) { if (Lock.empty() == true) @@ -415,6 +396,7 @@ string pkgAcquire::QueueName(string Uri,MethodConfig const *&Config) if (Config->SingleInstance == true || QueueMode == QueueAccess) return U.Access; + int Limit = 10; string AccessSchema = U.Access + ':'; string FullQueueName; @@ -433,15 +415,15 @@ string pkgAcquire::QueueName(string Uri,MethodConfig const *&Config) #ifdef _SC_NPROCESSORS_ONLN long cpuCount = sysconf(_SC_NPROCESSORS_ONLN) * 2; #else - long cpuCount = 10; + long cpuCount = Limit; #endif - cpuCount = _config->FindI("Acquire::QueueHost::Limit", cpuCount); + Limit = _config->FindI("Acquire::QueueHost::Limit", cpuCount); - if (cpuCount <= 0 || existing < cpuCount) + if (Limit <= 0 || existing < Limit) strprintf(FullQueueName, "%s%ld", AccessSchema.c_str(), existing); else { - long const randomQueue = random() % cpuCount; + long const randomQueue = random() % Limit; strprintf(FullQueueName, "%s%ld", AccessSchema.c_str(), randomQueue); } @@ -449,6 +431,7 @@ string pkgAcquire::QueueName(string Uri,MethodConfig const *&Config) clog << "Chose random queue " << FullQueueName << " for " << Uri << endl; } else { + Limit = _config->FindI("Acquire::QueueHost::Limit", Limit); FullQueueName = AccessSchema + U.Host; } unsigned int Instances = 0, SchemaLength = AccessSchema.length(); @@ -467,7 +450,7 @@ string pkgAcquire::QueueName(string Uri,MethodConfig const *&Config) clog << "Found " << Instances << " instances of " << U.Access << endl; } - if (Instances >= static_cast<decltype(Instances)>(_config->FindI("Acquire::QueueHost::Limit",10))) + if (Instances >= static_cast<decltype(Instances)>(Limit)) return U.Access; return FullQueueName; @@ -654,7 +637,7 @@ static void CheckDropPrivsMustBeDisabled(pkgAcquire const &Fetcher) // if its the source file (e.g. local sources) we might be lucky // by dropping the dropping only for some methods. - URI const source = (*I)->DescURI(); + URI const source((*I)->DescURI()); if (source.Access == "file" || source.Access == "copy") { std::string const conf = "Binary::" + source.Access + "::APT::Sandbox::User"; @@ -1301,13 +1284,13 @@ bool pkgAcquireStatus::Pulse(pkgAcquire *Owner) { if (I->CurrentItem != 0 && I->CurrentItem->Owner->Complete == false) { - CurrentBytes += I->CurrentSize; - ResumeSize += I->ResumePoint; + CurrentBytes += I->CurrentItem->CurrentSize; + ResumeSize += I->CurrentItem->ResumePoint; // Files with unknown size always have 100% completion if (I->CurrentItem->Owner->FileSize == 0 && I->CurrentItem->Owner->Complete == false) - TotalBytes += I->CurrentSize; + TotalBytes += I->CurrentItem->CurrentSize; } } @@ -1444,9 +1427,8 @@ void pkgAcquireStatus::Fetched(unsigned long long Size,unsigned long long Resume /*}}}*/ bool pkgAcquireStatus::ReleaseInfoChanges(metaIndex const * const LastRelease, metaIndex const * const CurrentRelease, std::vector<ReleaseInfoChange> &&Changes)/*{{{*/ { - auto const virt = dynamic_cast<pkgAcquireStatus2*>(this); - if (virt != nullptr) - return virt->ReleaseInfoChanges(LastRelease, CurrentRelease, std::move(Changes)); + (void) LastRelease; + (void) CurrentRelease; return ReleaseInfoChangesAsGlobalErrors(std::move(Changes)); } /*}}}*/ @@ -1464,12 +1446,6 @@ bool pkgAcquireStatus::ReleaseInfoChangesAsGlobalErrors(std::vector<ReleaseInfoC return AllOkay; } /*}}}*/ -bool pkgAcquireStatus2::ReleaseInfoChanges(metaIndex const * const, metaIndex const * const, std::vector<ReleaseInfoChange> &&Changes) -{ - return ReleaseInfoChangesAsGlobalErrors(std::move(Changes)); -} -pkgAcquireStatus2::pkgAcquireStatus2() : pkgAcquireStatus() {} -pkgAcquireStatus2::~pkgAcquireStatus2() {} pkgAcquire::UriIterator::UriIterator(pkgAcquire::Queue *Q) : d(NULL), CurQ(Q), CurItem(0) |