Skip to content

Commit

Permalink
Galaxy: Display progress bar per file instead of per chunk
Browse files Browse the repository at this point in the history
  • Loading branch information
Sude- committed Mar 18, 2024
1 parent 5cca5da commit d463c02
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
3 changes: 3 additions & 0 deletions include/downloader.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ struct xferInfo
Timer timer;
std::deque< std::pair<time_t, uintmax_t> > TimeAndSize;
curl_off_t offset;
bool isChunk = false;
curl_off_t chunk_file_total = 0;
curl_off_t chunk_file_offset = 0;
};

typedef struct
Expand Down
13 changes: 13 additions & 0 deletions src/downloader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3398,6 +3398,12 @@ int Downloader::progressCallbackForThread(void *clientp, curl_off_t dltotal, cur
info.dltotal = dltotal;
curl_off_t curl_rate;

if (xferinfo->isChunk)
{
info.dlnow += xferinfo->chunk_file_offset;
info.dltotal = xferinfo->chunk_file_total;
}

// trying to get rate and setting to NaN if it fails
if (CURLE_OK != curl_easy_getinfo(xferinfo->curlhandle, CURLINFO_SPEED_DOWNLOAD_T, &curl_rate))
info.rate_avg = std::numeric_limits<double>::quiet_NaN();
Expand Down Expand Up @@ -4159,6 +4165,10 @@ void Downloader::processGalaxyDownloadQueue(const std::string& install_path, Con
std::vector<std::string> cdnUrlTemplates;
while (dlQueueGalaxy.try_pop(item))
{
xferinfo.isChunk = false;
xferinfo.chunk_file_offset = 0;
xferinfo.chunk_file_total = item.totalSizeCompressed;

if (item.product_id != prev_product_id)
cdnUrlTemplates.clear();

Expand Down Expand Up @@ -4318,6 +4328,9 @@ void Downloader::processGalaxyDownloadQueue(const std::string& install_path, Con
}
for (unsigned int j = start_chunk; j < item.chunks.size(); ++j)
{
xferinfo.isChunk = true;
xferinfo.chunk_file_offset = item.chunks[j].offset_compressed; // Set offset for progress info

// Refresh Galaxy login if token is expired
if (galaxy->isTokenExpired())
{
Expand Down

0 comments on commit d463c02

Please sign in to comment.