FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > ArchLinux > ArchLinux Pacman Development

 
 
LinkBack Thread Tools
 
Old 09-08-2011, 01:30 AM
Dan McGee
 
Default account for partial delta files in download size

On Wed, Sep 7, 2011 at 6:19 PM, Dave Reisner <d@falconindy.com> wrote:
> 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>
> ---
> *lib/libalpm/delta.c | * 25 ++++++++++++++++++++-----
> *1 files changed, 20 insertions(+), 5 deletions(-)
>
> diff --git a/lib/libalpm/delta.c b/lib/libalpm/delta.c
> index 1ff4fde..da957bc 100644
> --- a/lib/libalpm/delta.c
> +++ b/lib/libalpm/delta.c
> @@ -89,12 +89,27 @@ 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);
> + * * * * * * * * * * * }
strcmp() fails, md5sum leaks.
> + * * * * * * * * * * * 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;
You were careful to keep it > 0 in the other patch; no need to do so here?
> + * * * * * * * * * * * * * * * }
> + * * * * * * * * * * * * * * * FREE(fpath);
> + * * * * * * * * * * * }
> + * * * * * * * * * * * FREE(fnamepart);
> * * * * * * * *}
> - * * * * * * * FREE(fpath);
> - * * * * * * * FREE(md5sum);
>
> * * * * * * * */* determine whether a base 'from' file exists */
> * * * * * * * *fpath = _alpm_filecache_find(handle, vdelta->from);
> --
> 1.7.6.1
>
>
>
 

Thread Tools




All times are GMT. The time now is 05:03 PM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org