create_work: use file_name as open_name when copy_file is set

If no open_name is specified in a file_ref element of the input template but copy_file is set for this file use the physical filename as logical filename.
This commit is contained in:
Christian Beer 2016-03-23 14:59:49 +01:00
parent 3f0cad3b4b
commit c57cee5ca6
1 changed files with 15 additions and 3 deletions

View File

@ -363,7 +363,7 @@ static int process_workunit(
break;
} else if (xp.match_tag("file_ref")) {
out += "<file_ref>\n";
bool found_file_number = false, found_open_name = false;
bool found_file_number = false, found_open_name = false, found_copy_file = false;
while (!xp.get_tag()) {
if (xp.parse_int("file_number", file_number)) {
INFILE_DESC& id = infiles[file_number];
@ -384,14 +384,26 @@ static int process_workunit(
out += buf;
found_open_name = true;
continue;
} else if (xp.match_tag("copy_file/")) {
out += " <copy_file/>\n";
found_copy_file = true;
continue;
} else if (xp.match_tag("/file_ref")) {
if (!found_file_number) {
fprintf(stderr, "No file number found\n");
return ERR_XML_PARSE;
}
if (!found_open_name) {
fprintf(stderr, "No open name found\n");
if (!found_open_name && !found_copy_file) {
fprintf(stderr, "No open name found and copy_file not specified\n");
return ERR_XML_PARSE;
} else if (!found_open_name && found_copy_file) {
INFILE_DESC& id = infiles[file_number];
if (id.is_remote) {
sprintf(buf, " <open_name>jf_%s</open_name>\n", infiles[file_number].md5);
} else {
sprintf(buf, " <open_name>%s</open_name>\n", infiles[file_number].name);
}
out += buf;
}
out += "</file_ref>\n";
break;