summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Reisner <dreisner@archlinux.org>2011-09-07 23:01:00 +0200
committerDan McGee <dan@archlinux.org>2011-09-12 02:10:48 +0200
commit3905ada993bacba31a1a9005fe4a0023890296d9 (patch)
tree6ed896f09603a9d7641683357da8a830f6b5599e
parentd8eacae7bc1465b725e6b1c3b7ad8c27c52437f4 (diff)
downloadpacman-3905ada993bacba31a1a9005fe4a0023890296d9.tar.gz
pacman-3905ada993bacba31a1a9005fe4a0023890296d9.tar.xz
account for partial delta files in download size
Similar to an earlier commit which accounts for .part files for full packages, calculate the download_size for deltas keeping mind the possibility of a partial transfer. Signed-off-by: Dave Reisner <dreisner@archlinux.org> Signed-off-by: Dan McGee <dan@archlinux.org>
-rw-r--r--lib/libalpm/delta.c26
1 files changed, 21 insertions, 5 deletions
diff --git a/lib/libalpm/delta.c b/lib/libalpm/delta.c
index 1ff4fde6..6315a851 100644
--- a/lib/libalpm/delta.c
+++ b/lib/libalpm/delta.c
@@ -89,12 +89,28 @@ static void graph_init_size(alpm_handle_t *handle, alpm_list_t *vertices)
/* determine whether the delta file already exists */
fpath = _alpm_filecache_find(handle, vdelta->delta);
- md5sum = alpm_compute_md5sum(fpath);
- if(fpath && md5sum && strcmp(md5sum, vdelta->delta_md5) == 0) {
- vdelta->download_size = 0;
+ if(fpath) {
+ md5sum = alpm_compute_md5sum(fpath);
+ if(md5sum && strcmp(md5sum, vdelta->delta_md5) == 0) {
+ vdelta->download_size = 0;
+ }
+ FREE(md5sum);
+ FREE(fpath);
+ } else {
+ char *fnamepart;
+ CALLOC(fnamepart, strlen(vdelta->delta) + 6, sizeof(char), return);
+ sprintf(fnamepart, "%s.part", vdelta->delta);
+ fpath = _alpm_filecache_find(handle, fnamepart);
+ if(fpath) {
+ struct stat st;
+ if(stat(fpath, &st) == 0) {
+ vdelta->download_size = vdelta->delta_size - st.st_size;
+ vdelta->download_size = vdelta->download_size < 0 ? 0 : vdelta->download_size;
+ }
+ FREE(fpath);
+ }
+ FREE(fnamepart);
}
- FREE(fpath);
- FREE(md5sum);
/* determine whether a base 'from' file exists */
fpath = _alpm_filecache_find(handle, vdelta->from);