From: Frank Schreiner Date: Tue, 22 Mar 2016 16:47:49 +0000 (+0000) Subject: added patch from mls X-Git-Tag: upstream/0.10.0~12^2~9 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=b6e49a9c91d624a7c58f646ab75031b76b6b2047;p=services%2Fcreaterepo_c.git added patch from mls --- diff --git a/src/dumper_thread.c b/src/dumper_thread.c index 3fe4c93..faf8cff 100644 --- a/src/dumper_thread.c +++ b/src/dumper_thread.c @@ -244,26 +244,26 @@ load_rpm(const char *fullpath, if (!pkg) goto errexit; - // cut off trailing slashes from urls e.g. media:// -> media: - gsize lb_length = strlen(location_base); - gchar *t_location_base = g_malloc0(sizeof(location_base)); - char suf[2]; - strncpy(suf,&location_base[lb_length-2],2); - - if ( g_strcmp0(suf,"//") == 0 ) { - t_location_base = g_strndup(location_base,lb_length-2); + + if (!media_id) { + pkg->location_base = cr_safe_string_chunk_insert(pkg->chunk, location_base); } else { - t_location_base = g_strdup(location_base); + // default location_base "media:" in split mode + if (!location_base) + location_base = "media:"; + + // calculate location_base + size_t lb_length = strlen(location_base); + gchar *t_location_base = g_malloc0(lb_length + 32); + strcpy(t_location_base, location_base); + if (lb_length > 2 && g_strcmp0(location_base + lb_length - 3, "://") == 0) + lb_length -= 2; + sprintf(t_location_base + lb_length, "#%d", media_id); + pkg->location_base = cr_safe_string_chunk_insert(pkg->chunk, t_location_base); + g_free(t_location_base); } - // if --split option was given, the media_id == 0 - if ( media_id > 0 ) - sprintf(t_location_base,"%s#%i",t_location_base,media_id); - pkg->location_href = cr_safe_string_chunk_insert(pkg->chunk, location_href); - pkg->location_base = cr_safe_string_chunk_insert(pkg->chunk, t_location_base); - - g_free(t_location_base); // Get checksum type string pkg->checksum_type = cr_safe_string_chunk_insert(pkg->chunk,