summaryrefslogtreecommitdiff
path: root/apt-pkg
diff options
context:
space:
mode:
authorArch Librarian <arch@canonical.com>2004-09-20 16:53:18 +0000
committerArch Librarian <arch@canonical.com>2004-09-20 16:53:18 +0000
commit6b1ff003a4acd2914dd395b651c485fb352e3d1a (patch)
treeac0b53eca20edab2d4f5dff7aa22411a2f8f0963 /apt-pkg
parenta9a5908db9fa6ee108fb23f516b422aa9ca47120 (diff)
downloadapt-6b1ff003a4acd2914dd395b651c485fb352e3d1a.tar.gz
Checked the size of partial files #33705
Author: jgg Date: 1999-03-27 03:02:38 GMT Checked the size of partial files #33705
Diffstat (limited to 'apt-pkg')
-rw-r--r--apt-pkg/acquire-item.cc22
-rw-r--r--apt-pkg/acquire-item.h3
-rw-r--r--apt-pkg/acquire.cc14
-rw-r--r--apt-pkg/acquire.h3
4 files changed, 33 insertions, 9 deletions
diff --git a/apt-pkg/acquire-item.cc b/apt-pkg/acquire-item.cc
index 7e4ea504..0b1d2a5b 100644
--- a/apt-pkg/acquire-item.cc
+++ b/apt-pkg/acquire-item.cc
@@ -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);
diff --git a/apt-pkg/acquire-item.h b/apt-pkg/acquire-item.h
index fd01bbb9..e5e7c701 100644
--- a/apt-pkg/acquire-item.h
+++ b/apt-pkg/acquire-item.h
@@ -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;
diff --git a/apt-pkg/acquire.cc b/apt-pkg/acquire.cc
index 22127659..2e8a05e2 100644
--- a/apt-pkg/acquire.cc
+++ b/apt-pkg/acquire.cc
@@ -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 /*{{{*/
// ---------------------------------------------------------------------
/* */
diff --git a/apt-pkg/acquire.h b/apt-pkg/acquire.h
index 5693615d..156fc7aa 100644
--- a/apt-pkg/acquire.h
+++ b/apt-pkg/acquire.h
@@ -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();