Browse Source

acq: worker: Move CurrentSize, TotalSize, ResumePoint to CurrentItem

These status fields belong to the current item, move them there. This
prepares us for eventually having multiple current items.
tags/devuan/2.0.1+devuan1
Julian Andres Klode 1 year ago
parent
commit
cccef6ca60
5 changed files with 32 additions and 34 deletions
  1. +7
    -9
      apt-pkg/acquire-worker.cc
  2. +0
    -15
      apt-pkg/acquire-worker.h
  3. +3
    -3
      apt-pkg/acquire.cc
  4. +15
    -0
      apt-pkg/acquire.h
  5. +7
    -7
      apt-private/acqprogress.cc

+ 7
- 9
apt-pkg/acquire-worker.cc View File

@@ -44,7 +44,7 @@ using namespace std;
// Worker::Worker - Constructor for Queue startup /*{{{*/
pkgAcquire::Worker::Worker(Queue *Q, MethodConfig *Cnf, pkgAcquireStatus *log) :
d(NULL), OwnerQ(Q), Log(log), Config(Cnf), Access(Cnf->Access),
CurrentItem(nullptr), CurrentSize(0), TotalSize(0)
CurrentItem(nullptr)
{
Construct();
}
@@ -369,12 +369,12 @@ bool pkgAcquire::Worker::RunMessages()
}

CurrentItem = Itm;
CurrentSize = 0;
TotalSize = strtoull(LookupTag(Message,"Size","0").c_str(), NULL, 10);
ResumePoint = strtoull(LookupTag(Message,"Resume-Point","0").c_str(), NULL, 10);
Itm->CurrentSize = 0;
Itm->TotalSize = strtoull(LookupTag(Message,"Size","0").c_str(), NULL, 10);
Itm->ResumePoint = strtoull(LookupTag(Message,"Resume-Point","0").c_str(), NULL, 10);
for (auto const Owner: Itm->Owners)
{
Owner->Start(Message, TotalSize);
Owner->Start(Message, Itm->TotalSize);
// Display update before completion
if (Log != nullptr)
{
@@ -918,7 +918,7 @@ void pkgAcquire::Worker::Pulse()
struct stat Buf;
if (stat(CurrentItem->Owner->DestFile.c_str(),&Buf) != 0)
return;
CurrentSize = Buf.st_size;
CurrentItem->CurrentSize = Buf.st_size;
}
/*}}}*/
// Worker::ItemDone - Called when the current item is finished /*{{{*/
@@ -926,9 +926,7 @@ void pkgAcquire::Worker::Pulse()
/* */
void pkgAcquire::Worker::ItemDone()
{
CurrentItem = 0;
CurrentSize = 0;
TotalSize = 0;
CurrentItem = nullptr;
Status = string();
}
/*}}}*/


+ 0
- 15
apt-pkg/acquire-worker.h View File

@@ -251,21 +251,6 @@ class pkgAcquire::Worker : public WeakPointable
*/
std::string Status;

/** \brief How many bytes of the file have been downloaded. Zero
* if the current progress of the file cannot be determined.
*/
unsigned long long CurrentSize;

/** \brief The total number of bytes to be downloaded. Zero if the
* total size of the final is unknown.
*/
unsigned long long TotalSize;

/** \brief How much of the file was already downloaded prior to
* starting this worker.
*/
unsigned long long ResumePoint;
/** \brief Tell the subprocess to download the given item.
*
* \param Item the item to queue up.


+ 3
- 3
apt-pkg/acquire.cc View File

@@ -1284,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;
}
}


+ 15
- 0
apt-pkg/acquire.h View File

@@ -425,6 +425,21 @@ class pkgAcquire::Queue
/** \brief The underlying items interested in the download */
std::vector<Item*> Owners;

/** \brief How many bytes of the file have been downloaded. Zero
* if the current progress of the file cannot be determined.
*/
unsigned long long CurrentSize = 0;

/** \brief The total number of bytes to be downloaded. Zero if the
* total size of the final is unknown.
*/
unsigned long long TotalSize = 0;

/** \brief How much of the file was already downloaded prior to
* starting this worker.
*/
unsigned long long ResumePoint = 0;

typedef std::vector<Item*>::const_iterator owner_iterator;

/** \brief Assign the ItemDesc portion of this QItem from


+ 7
- 7
apt-private/acqprogress.cc View File

@@ -221,21 +221,21 @@ bool AcqTextStatus::Pulse(pkgAcquire *Owner)
enum {Long = 0,Medium,Short} Mode = Medium;
// Add the current progress
if (Mode == Long)
S << " " << std::to_string(I->CurrentSize);
S << " " << std::to_string(I->CurrentItem->CurrentSize);
else
{
if (Mode == Medium || I->TotalSize == 0)
S << " " << SizeToStr(I->CurrentSize) << "B";
if (Mode == Medium || I->CurrentItem->TotalSize == 0)
S << " " << SizeToStr(I->CurrentItem->CurrentSize) << "B";
}

// Add the total size and percent
if (I->TotalSize > 0 && I->CurrentItem->Owner->Complete == false)
if (I->CurrentItem->TotalSize > 0 && I->CurrentItem->Owner->Complete == false)
{
if (Mode == Short)
ioprintf(S, " %.0f%%", (I->CurrentSize*100.0)/I->TotalSize);
ioprintf(S, " %.0f%%", (I->CurrentItem->CurrentSize*100.0)/I->CurrentItem->TotalSize);
else
ioprintf(S, "/%sB %.0f%%", SizeToStr(I->TotalSize).c_str(),
(I->CurrentSize*100.0)/I->TotalSize);
ioprintf(S, "/%sB %.0f%%", SizeToStr(I->CurrentItem->TotalSize).c_str(),
(I->CurrentItem->CurrentSize*100.0)/I->CurrentItem->TotalSize);
}
S << "]";
}


Loading…
Cancel
Save