>From a7978778db4501b872b0946346c2dedd8e12769d Mon Sep 17 00:00:00 2001
From: Matthew White
Date: Thu, 28 Jul 2016 17:10:46 +0200
Subject: [PATCH 1/2] Bugfix: create/download/verify Metalink's files with a
"path/file" format
* src/metalink.c (retrieve_from_metalink): Set filename to mfile->name
to create/download/verify files with a "path/file" format
Bug:
* src/utils.c (unique_create, fopen_excl): cannot create "path/file"
* src/metalink.c (retrieve_from_metalink): when filename is NULL,
"path/file" is downloaded as "file", and it cannot be verified
The directory information contained in a metalink:file element shall
be used in the same way the option --directory-prefix will.
--directory-prefix="dirA/dirB/file.gz"
This patch conforms to the RFC5854 specification:
The Metalink Download Description Format
4.1.2.1. The "name" Attribute
https://tools.ietf.org/html/rfc5854#section-4.1.2.1
---
src/metalink.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/src/metalink.c b/src/metalink.c
index 9f34b32..dd16db2 100644
--- a/src/metalink.c
+++ b/src/metalink.c
@@ -156,6 +156,13 @@ retrieve_from_metalink (const metalink_t* metalink)
output_stream = unique_create (mfile->name, true, &filename);
output_stream_regular = true;
+ /* Bug: utils.h (unique_create): cannot create a
+ "path/file" tree. Bugfix: If filename is set to
+ "path/file", a tree is created in the same way as
+ --directory-prefix does (see RFC5854). */
+ if (filename == NULL && mfile->name)
+ filename = xstrdup (mfile->name);
+
/* Store the real file name for displaying in messages. */
opt.output_document = filename;
--
2.7.3