]> git.saurik.com Git - apt.git/commitdiff
Checked the size of partial files #33705
authorArch Librarian <arch@canonical.com>
Mon, 20 Sep 2004 16:53:18 +0000 (16:53 +0000)
committerArch Librarian <arch@canonical.com>
Mon, 20 Sep 2004 16:53:18 +0000 (16:53 +0000)
Author: jgg
Date: 1999-03-27 03:02:38 GMT
Checked the size of partial files #33705

apt-pkg/acquire-item.cc
apt-pkg/acquire-item.h
apt-pkg/acquire.cc
apt-pkg/acquire.h
cmdline/apt-get.cc

index 7e4ea5043a514fc63a66dd2758a868686aca38cd..0b1d2a5ba2fa94ceb1e6a34bd6d8a6b43685dff8 100644 (file)
@@ -1,6 +1,6 @@
 // -*- mode: cpp; mode: fold -*-
 // Description                                                         /*{{{*/
-// $Id: acquire-item.cc,v 1.25 1999/02/27 22:29:11 jgg Exp $
+// $Id: acquire-item.cc,v 1.26 1999/03/27 03:02:38 jgg Exp $
 /* ######################################################################
 
    Acquire Item - Item to acquire
@@ -32,8 +32,8 @@
 // ---------------------------------------------------------------------
 /* */
 pkgAcquire::Item::Item(pkgAcquire *Owner) : Owner(Owner), FileSize(0),
-                       Mode(0), ID(0), Complete(false), Local(false), 
-                       QueueCounter(0)
+                       PartialSize(0), Mode(0), ID(0), Complete(false), 
+                       Local(false), QueueCounter(0)
 {
    Owner->Add(this);
    Status = StatIdle;
@@ -425,8 +425,8 @@ bool pkgAcqArchive::QueueNext()
            return true;
         }
         
-        /* Hmm, we have a file and its size does not match, this shouldnt
-           happen.. */
+        /* Hmm, we have a file and its size does not match, this means it is
+           an old style mismatched arch */
         unlink(FinalFile.c_str());
       }
 
@@ -450,7 +450,17 @@ bool pkgAcqArchive::QueueNext()
       }
 
       DestFile = _config->FindDir("Dir::Cache::Archives") + "partial/" + flNotDir(StoreFilename);
-
+      
+      // Check the destination file
+      if (stat(DestFile.c_str(),&Buf) == 0)
+      {
+        // Hmm, the partial file is too big, erase it
+        if ((unsigned)Buf.st_size > Version->Size)
+           unlink(DestFile.c_str());
+        else
+           PartialSize = Buf.st_size;
+      }
+      
       // Create the item
       Desc.URI = Location->ArchiveURI(PkgFile);
       Desc.Description = Location->ArchiveInfo(Version);
index fd01bbb9a32c6323bdcf4d9f9fe2710a971308ee..e5e7c701d5d69086bd551dcb196f317cf26d34c7 100644 (file)
@@ -1,6 +1,6 @@
 // -*- mode: cpp; mode: fold -*-
 // Description                                                         /*{{{*/
-// $Id: acquire-item.h,v 1.16 1999/02/01 02:22:11 jgg Exp $
+// $Id: acquire-item.h,v 1.17 1999/03/27 03:02:38 jgg Exp $
 /* ######################################################################
 
    Acquire Item - Item to acquire
@@ -48,6 +48,7 @@ class pkgAcquire::Item
    enum {StatIdle, StatFetching, StatDone, StatError} Status;
    string ErrorText;
    unsigned long FileSize;
+   unsigned long PartialSize;   
    char *Mode;
    unsigned long ID;
    bool Complete;
index 221276597dd399b5c7bc0b423b3a39d4a807021f..2e8a05e2cec6965de074691acb89011bab1c9479 100644 (file)
@@ -1,6 +1,6 @@
 // -*- mode: cpp; mode: fold -*-
 // Description                                                         /*{{{*/
-// $Id: acquire.cc,v 1.30 1999/03/16 07:28:45 jgg Exp $
+// $Id: acquire.cc,v 1.31 1999/03/27 03:02:38 jgg Exp $
 /* ######################################################################
 
    Acquire - File Acquiration
@@ -420,6 +420,18 @@ unsigned long pkgAcquire::FetchNeeded()
    return Total;
 }
                                                                        /*}}}*/
+// Acquire::PartialPresent - Number of partial bytes we already have   /*{{{*/
+// ---------------------------------------------------------------------
+/* This is the number of bytes that is not local */
+unsigned long pkgAcquire::PartialPresent()
+{
+   unsigned long Total = 0;
+   for (pkgAcquire::Item **I = ItemsBegin(); I != ItemsEnd(); I++)
+      if ((*I)->Local == false)
+        Total += (*I)->PartialSize;
+   return Total;
+}
+                                                                       /*}}}*/
 // pkgAcquire::UriBegin - Start iterator for the uri list              /*{{{*/
 // ---------------------------------------------------------------------
 /* */
index 5693615ddc6c1ffd78303419bea6586784b57bdd..156fc7aaec373779a799e610cf1750be69b8a0ca 100644 (file)
@@ -1,6 +1,6 @@
 // -*- mode: cpp; mode: fold -*-
 // Description                                                         /*{{{*/
-// $Id: acquire.h,v 1.19 1999/01/30 06:07:24 jgg Exp $
+// $Id: acquire.h,v 1.20 1999/03/27 03:02:39 jgg Exp $
 /* ######################################################################
 
    Acquire - File Acquiration
@@ -110,6 +110,7 @@ class pkgAcquire
    // Returns the size of the total download set
    unsigned long TotalNeeded();
    unsigned long FetchNeeded();
+   unsigned long PartialPresent();
    
    pkgAcquire(pkgAcquireStatus *Log = 0);
    ~pkgAcquire();
index 81c350dfa52dd2dbf5d4f5c095a19f9b3ac12633..73397e8aeab1446f688df3fd0a72cbbaaf4f1254 100644 (file)
@@ -1,6 +1,6 @@
 // -*- mode: cpp; mode: fold -*-
 // Description                                                         /*{{{*/
-// $Id: apt-get.cc,v 1.46 1999/03/27 01:30:38 jgg Exp $
+// $Id: apt-get.cc,v 1.47 1999/03/27 03:02:39 jgg Exp $
 /* ######################################################################
    
    apt-get - Cover for dpkg
@@ -543,6 +543,7 @@ bool InstallPackages(CacheFile &Cache,bool ShwKept,bool Ask = true,bool Saftey =
 
    // Display statistics
    unsigned long FetchBytes = Fetcher.FetchNeeded();
+   unsigned long FetchPBytes = Fetcher.PartialPresent();
    unsigned long DebBytes = Fetcher.TotalNeeded();
    if (DebBytes != Cache->DebSize())
    {
@@ -556,7 +557,7 @@ bool InstallPackages(CacheFile &Cache,bool ShwKept,bool Ask = true,bool Saftey =
    if (statfs(OutputDir.c_str(),&Buf) != 0)
       return _error->Errno("statfs","Couldn't determine free space in %s",
                           OutputDir.c_str());
-   if (unsigned(Buf.f_bfree) < FetchBytes/Buf.f_bsize)
+   if (unsigned(Buf.f_bfree) < (FetchBytes - FetchPBytes)/Buf.f_bsize)
       return _error->Error("Sorry, you don't have enough free space in %s",
                           OutputDir.c_str());