From b4e57d2dd44728929cb83113ed79c8e16405767e Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Wed, 30 Nov 2005 13:53:44 +0000 Subject: * hack around local file:/ uri problem --- apt-pkg/acquire-item.cc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/apt-pkg/acquire-item.cc b/apt-pkg/acquire-item.cc index 8a9a4c5bb..ad977dde4 100644 --- a/apt-pkg/acquire-item.cc +++ b/apt-pkg/acquire-item.cc @@ -165,11 +165,15 @@ pkgAcqDiffIndex::pkgAcqDiffIndex(pkgAcquire *Owner, CurrentPackagesFile = _config->FindDir("Dir::State::lists"); CurrentPackagesFile += URItoFileName(RealURI); + // FIXME: this file:/ check is a hack to prevent fetching + // from local sources. this is really silly, and + // should be fixed cleanly as soon as possible if(!FileExists(CurrentPackagesFile) || + Desc.URI.substr(0,strlen("file:/")) == "file:/" || !_config->FindB("Acquire::Diffs",true)) { // we don't have a pkg file or we don't want to queue if(Debug) - std::clog << "No index file or canceld by user" << std::endl; + std::clog << "No index file, local or canceld by user" << std::endl; Failed("", NULL); return; } -- cgit v1.2.3 From 2ac3eeb60e9ea171cee7a05a02424e61fe50d400 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Thu, 30 Mar 2006 10:38:14 +0200 Subject: * make the code follow the apt coding standards better * change the location to turn off pdiff (APT::PDiff=false) --- apt-pkg/acquire-item.cc | 61 +++++++++++++++++++++++++++++--------------- doc/examples/configure-index | 2 ++ 2 files changed, 43 insertions(+), 20 deletions(-) diff --git a/apt-pkg/acquire-item.cc b/apt-pkg/acquire-item.cc index ad977dde4..d845d4605 100644 --- a/apt-pkg/acquire-item.cc +++ b/apt-pkg/acquire-item.cc @@ -170,7 +170,8 @@ pkgAcqDiffIndex::pkgAcqDiffIndex(pkgAcquire *Owner, // should be fixed cleanly as soon as possible if(!FileExists(CurrentPackagesFile) || Desc.URI.substr(0,strlen("file:/")) == "file:/" || - !_config->FindB("Acquire::Diffs",true)) { + !_config->FindB("Acquire::Diffs",true)) + { // we don't have a pkg file or we don't want to queue if(Debug) std::clog << "No index file, local or canceld by user" << std::endl; @@ -178,11 +179,10 @@ pkgAcqDiffIndex::pkgAcqDiffIndex(pkgAcquire *Owner, return; } - if(Debug) { + if(Debug) std::clog << "pkgAcqIndexDiffs::pkgAcqIndexDiffs(): " << CurrentPackagesFile << std::endl; - } - + QueueURI(Desc); } @@ -237,26 +237,32 @@ bool pkgAcqDiffIndex::ParseDiffIndex(string IndexDiffFile) SHA1.AddFD(fd.Fd(), fd.Size()); local_sha1 = string(SHA1.Result()); - if(local_sha1 == ServerSha1) { + if(local_sha1 == ServerSha1) + { + // we have the same sha1 as the server if(Debug) std::clog << "Package file is up-to-date" << std::endl; // set found to true, this will queue a pkgAcqIndexDiffs with // a empty availabe_patches found = true; - } else { + } + else + { if(Debug) std::clog << "SHA1-Current: " << ServerSha1 << std::endl; // check the historie and see what patches we need string history = Tags.FindS("SHA1-History"); std::stringstream hist(history); - while(hist >> d.sha1 >> size >> d.file) { + while(hist >> d.sha1 >> size >> d.file) + { d.size = atoi(size.c_str()); // read until the first match is found if(d.sha1 == local_sha1) found=true; // from that point on, we probably need all diffs - if(found) { + if(found) + { if(Debug) std::clog << "Need to get diff: " << d.file << std::endl; available_patches.push_back(d); @@ -265,12 +271,15 @@ bool pkgAcqDiffIndex::ParseDiffIndex(string IndexDiffFile) } // no information how to get the patches, bail out - if(!found) { + if(!found) + { if(Debug) std::clog << "Can't find a patch in the index file" << std::endl; // Failed will queue a big package file Failed("", NULL); - } else { + } + else + { // queue the diffs new pkgAcqIndexDiffs(Owner, RealURI, Description, Desc.ShortDesc, ExpectedMD5, available_patches); @@ -351,10 +360,13 @@ pkgAcqIndexDiffs::pkgAcqIndexDiffs(pkgAcquire *Owner, Desc.Owner = this; Desc.ShortDesc = ShortDesc; - if(available_patches.size() == 0) { + if(available_patches.size() == 0) + { // we are done (yeah!) Finish(true); - } else { + } + else + { // get the next diff State = StateFetchDiff; QueueNextDiff(); @@ -378,7 +390,8 @@ void pkgAcqIndexDiffs::Finish(bool allDone) { // we restore the original name, this is required, otherwise // the file will be cleaned - if(allDone) { + if(allDone) + { DestFile = _config->FindDir("Dir::State::lists"); DestFile += URItoFileName(RealURI); @@ -435,14 +448,17 @@ bool pkgAcqIndexDiffs::QueueNextDiff() // remove all patches until the next matching patch is found // this requires the Index file to be ordered for(vector::iterator I=available_patches.begin(); - available_patches.size() > 0 && I != available_patches.end() - && (*I).sha1 != local_sha1; - I++) { + available_patches.size() > 0 && + I != available_patches.end() && + (*I).sha1 != local_sha1; + I++) + { available_patches.erase(I); } // error checking and falling back if no patch was found - if(available_patches.size() == 0) { + if(available_patches.size() == 0) + { Failed("", NULL); return false; } @@ -1009,9 +1025,14 @@ void pkgAcqMetaIndex::QueueIndexes(bool verify) } } - // Queue Packages file - new pkgAcqDiffIndex(Owner, (*Target)->URI, (*Target)->Description, - (*Target)->ShortDesc, ExpectedIndexMD5); + // Queue Packages file (either diff or full packages files, depending + // on the users option) + if(_config->FindB("Acquire::PDiffs",false) == false) + new pkgAcqDiffIndex(Owner, (*Target)->URI, (*Target)->Description, + (*Target)->ShortDesc, ExpectedIndexMD5); + else + new newPkgAcqIndex(Owner, (*Target)->URI, (*Target)->Description, + (*Target)->ShortDesc, ExpectedIndexMD5); } } diff --git a/doc/examples/configure-index b/doc/examples/configure-index index dee0c06ff..965a09759 100644 --- a/doc/examples/configure-index +++ b/doc/examples/configure-index @@ -99,6 +99,8 @@ Acquire Queue-Mode "host"; // host|access Retries "0"; Source-Symlinks "true"; + + PDiffs "true"; // try to get the IndexFile diffs // HTTP method configuration http -- cgit v1.2.3 From 81fcf9e22b9f93896ceb644c9341d9d53da9c790 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Thu, 30 Mar 2006 10:52:32 +0200 Subject: * fix FTBFS --- apt-pkg/acquire-item.cc | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/apt-pkg/acquire-item.cc b/apt-pkg/acquire-item.cc index d845d4605..38977d2b1 100644 --- a/apt-pkg/acquire-item.cc +++ b/apt-pkg/acquire-item.cc @@ -169,8 +169,7 @@ pkgAcqDiffIndex::pkgAcqDiffIndex(pkgAcquire *Owner, // from local sources. this is really silly, and // should be fixed cleanly as soon as possible if(!FileExists(CurrentPackagesFile) || - Desc.URI.substr(0,strlen("file:/")) == "file:/" || - !_config->FindB("Acquire::Diffs",true)) + Desc.URI.substr(0,strlen("file:/")) == "file:/") { // we don't have a pkg file or we don't want to queue if(Debug) @@ -1031,7 +1030,7 @@ void pkgAcqMetaIndex::QueueIndexes(bool verify) new pkgAcqDiffIndex(Owner, (*Target)->URI, (*Target)->Description, (*Target)->ShortDesc, ExpectedIndexMD5); else - new newPkgAcqIndex(Owner, (*Target)->URI, (*Target)->Description, + new pkgAcqIndex(Owner, (*Target)->URI, (*Target)->Description, (*Target)->ShortDesc, ExpectedIndexMD5); } } -- cgit v1.2.3 From 8f30ca302e4235985982a0f2b1e83dfe977ed12c Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Sun, 2 Apr 2006 13:02:02 +0200 Subject: * fix in the log class to avoid absurdely big downloads --- apt-pkg/acquire-item.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/apt-pkg/acquire-item.cc b/apt-pkg/acquire-item.cc index 38977d2b1..a29063e1a 100644 --- a/apt-pkg/acquire-item.cc +++ b/apt-pkg/acquire-item.cc @@ -103,7 +103,8 @@ void pkgAcquire::Item::Done(string Message,unsigned long Size,string, { // We just downloaded something.. string FileName = LookupTag(Message,"Filename"); - if (Complete == false && FileName == DestFile) + // we only inform the Log class if it was actually not a local thing + if (Complete == false && !Local && FileName == DestFile) { if (Owner->Log != 0) Owner->Log->Fetched(Size,atoi(LookupTag(Message,"Resume-Point","0").c_str())); -- cgit v1.2.3