librepo/PR138-Fix-progress-reporting-with-zchunk-files.patch
Neal Gompa ba6236d07a - Upgrade to 1.9.3
+ Replace expat with libxml2
  + Support using python-gpg instead of pygpgme
  + Fix major performance regression with libcurl-7.61.1
  + Add zchunk support
- Drop patch for backported fix that is part of this release
  * Patch: 0001-stop-requiring-attr-xattr.patch
- Add patch proposed upstream to fix progress reporting for zck
  * Patch: PR138-Fix-progress-reporting-with-zchunk-files.patch
- Fix RPM group and description for Python 3 subpackage
- Drop Python 2 subpackage

OBS-URL: https://build.opensuse.org/package/show/system:packagemanager:dnf/librepo?expand=0&rev=11
2019-02-03 18:10:44 +00:00

82 lines
3.2 KiB
Diff

From 746c0904d663d2bca38b9dc83708b763c333851b Mon Sep 17 00:00:00 2001
From: Jonathan Dieter <jdieter@gmail.com>
Date: Tue, 1 Jan 2019 15:10:24 +0000
Subject: [PATCH] Fix progress reporting with zchunk files
Currently, when downloading a zchunk file, the progress bar gets reset to
zero when the header is finished downloading. This patch fixes that bug.
Signed-off-by: Jonathan Dieter <jdieter@gmail.com>
---
librepo/downloader.c | 18 ++++++++++++++++++
librepo/downloadtarget.h | 6 ++++++
2 files changed, 24 insertions(+)
diff --git a/librepo/downloader.c b/librepo/downloader.c
index 9724409..53bb5c9 100644
--- a/librepo/downloader.c
+++ b/librepo/downloader.c
@@ -414,6 +414,13 @@ lr_progresscb(void *ptr,
if (!target->target->progresscb)
return ret;
+#ifdef WITH_ZCHUNK
+ if (target->target->is_zchunk) {
+ total_to_download = target->target->total_to_download;
+ now_downloaded = now_downloaded + target->target->downloaded;
+ }
+#endif /* WITH_ZCHUNK */
+
ret = target->target->progresscb(target->target->cbdata,
total_to_download,
now_downloaded);
@@ -1106,6 +1113,7 @@ prep_zck_header(LrTarget *target, GError **err)
target->target->zck_dl = zck_dl_init(zck);
}
target->target->range = zck_get_range(0, target->target->zck_header_size-1);
+ target->target->total_to_download = target->target->zck_header_size;
target->target->resume = 0;
target->zck_state = LR_ZCK_DL_HEADER;
return lr_zck_clear_header(target, err);
@@ -1174,6 +1182,11 @@ find_local_zck_chunks(LrTarget *target, GError **err)
g_slist_free_full(filelist, free);
free(uf);
}
+ target->target->downloaded = target->target->total_to_download;
+ /* Calculate how many bytes need to be downloaded */
+ for(zckChunk *idx = zck_get_first_chunk(zck); idx != NULL; idx = zck_get_next_chunk(idx))
+ if(zck_get_chunk_valid(idx) != 1)
+ target->target->total_to_download += zck_get_chunk_comp_size(idx) + 92; /* Estimate of multipart overhead */
target->zck_state = LR_ZCK_DL_BODY;
return TRUE;
}
@@ -1299,6 +1312,11 @@ check_zck(LrTarget *target, GError **err)
}
}
zck_reset_failed_chunks(zck);
+ /* Recalculate how many bytes remain to be downloaded by subtracting from total_to_download */
+ target->target->downloaded = target->target->total_to_download;
+ for(zckChunk *idx = zck_get_first_chunk(zck); idx != NULL; idx = zck_get_next_chunk(idx))
+ if(zck_get_chunk_valid(idx) != 1)
+ target->target->downloaded -= zck_get_chunk_comp_size(idx) + 92;
return prep_zck_body(target, err);
}
#endif /* WITH_ZCHUNK */
diff --git a/librepo/downloadtarget.h b/librepo/downloadtarget.h
index 59bd1a8..f4c1f26 100644
--- a/librepo/downloadtarget.h
+++ b/librepo/downloadtarget.h
@@ -152,6 +152,12 @@ typedef struct {
gint64 zck_header_size; /*!<
Zchunk header size */
+
+ double total_to_download; /*!<
+ Total to download in zchunk file */
+
+ double downloaded; /*!<
+ Amount already downloaded in zchunk file */
#endif /* WITH_ZCHUNK */
} LrDownloadTarget;