]> git.saurik.com Git - apt.git/blobdiff - apt-pkg/acquire.cc
Merge remote-tracking branch 'upstream/debian/experimental' into feature/acq-trans
[apt.git] / apt-pkg / acquire.cc
index 37964c943685c9747d62a329be3e9d9c577ff647..9060d492b8d5bce46a98d795219455b8bb05b3d2 100644 (file)
@@ -37,6 +37,7 @@
 #include <sys/time.h>
 #include <sys/select.h>
 #include <errno.h>
+#include <sys/stat.h>
 
 #include <apti18n.h>
                                                                        /*}}}*/
@@ -487,6 +488,9 @@ bool pkgAcquire::Clean(string Dir)
    if (DirectoryExists(Dir) == false)
       return true;
 
+   if(Dir == "/")
+      return _error->Error(_("Clean of %s is not supported"), Dir.c_str());
+
    DIR *D = opendir(Dir.c_str());   
    if (D == 0)
       return _error->Errno("opendir",_("Unable to read %s"),Dir.c_str());
@@ -822,7 +826,9 @@ bool pkgAcquireStatus::Pulse(pkgAcquire *Owner)
    // Compute the total number of bytes to fetch
    unsigned int Unknown = 0;
    unsigned int Count = 0;
-   for (pkgAcquire::ItemCIterator I = Owner->ItemsBegin(); I != Owner->ItemsEnd();
+   bool UnfetchedReleaseFiles = false;
+   for (pkgAcquire::ItemCIterator I = Owner->ItemsBegin(); 
+        I != Owner->ItemsEnd();
        ++I, ++Count)
    {
       TotalItems++;
@@ -836,6 +842,10 @@ bool pkgAcquireStatus::Pulse(pkgAcquire *Owner)
       // see if the method tells us to expect more
       TotalItems += (*I)->ExpectedAdditionalItems;
 
+      // check if there are unfetched Release files
+      if ((*I)->Complete == false && (*I)->ExpectedAdditionalItems > 0)
+         UnfetchedReleaseFiles = true;
+
       TotalBytes += (*I)->FileSize;
       if ((*I)->Complete == true)
         CurrentBytes += (*I)->FileSize;
@@ -895,9 +905,8 @@ bool pkgAcquireStatus::Pulse(pkgAcquire *Owner)
       Time = NewTime;
    }
 
-   // calculate the percentage, if we have too little data assume 0%
-   // FIXME: the 5k is totally arbitrary 
-   if (TotalBytes < 5*1024)
+   // calculate the percentage, if we have too little data assume 1%
+   if (TotalBytes > 0 && UnfetchedReleaseFiles)
       Percent = 0;
    else 
       // use both files and bytes because bytes can be unreliable