Skip to content

Commit b8e59aa

Browse files
committed
More careful construction of temp archive name -- careful for separating '/'
Also avoid putting duplicate oso files in the tar file.
1 parent bdcca08 commit b8e59aa

1 file changed

Lines changed: 10 additions & 6 deletions

File tree

src/liboslexec/shadingsys.cpp

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2491,7 +2491,7 @@ ShadingSystemImpl::archive_shadergroup (ShaderGroup *group, string_view filename
24912491
}
24922492
filename_base.erase (filename_base.size() - extension.size());
24932493

2494-
std::string pattern = OIIO::Filesystem::temp_directory_path() + "OSL-%%%%-%%%%";
2494+
std::string pattern = OIIO::Filesystem::temp_directory_path() + "/OSL-%%%%-%%%%";
24952495
if (! pattern.size()) {
24962496
error ("archive_shadergroup: Could not find a temp directory");
24972497
return false;
@@ -2504,8 +2504,8 @@ ShadingSystemImpl::archive_shadergroup (ShaderGroup *group, string_view filename
25042504
std::string errmessage;
25052505
bool dir_ok = OIIO::Filesystem::create_directory (tmpdir, errmessage);
25062506
if (! dir_ok) {
2507-
error ("archive_shadergroup: Could not create temp directory: %s",
2508-
errmessage);
2507+
error ("archive_shadergroup: Could not create temp directory %s (%s)",
2508+
tmpdir, errmessage);
25092509
return false;
25102510
}
25112511

@@ -2523,12 +2523,16 @@ ShadingSystemImpl::archive_shadergroup (ShaderGroup *group, string_view filename
25232523
std::string filename_list = "shadergroup";
25242524
{
25252525
boost::lock_guard<ShaderGroup> lock (*group);
2526+
std::set<std::string> entries; // to avoid duplicates
25262527
for (int i = 0, nl = group->nlayers(); i < nl; ++i) {
25272528
std::string osofile = (*group)[i]->master()->osofilename();
25282529
std::string osoname = OIIO::Filesystem::filename (osofile);
2529-
std::string localfile = tmpdir + "/" + osoname;
2530-
OIIO::Filesystem::copy (osofile, localfile);
2531-
filename_list += " " + osoname;
2530+
if (entries.find(osoname) == entries.end()) {
2531+
entries.insert (osoname);
2532+
std::string localfile = tmpdir + "/" + osoname;
2533+
OIIO::Filesystem::copy (osofile, localfile);
2534+
filename_list += " " + osoname;
2535+
}
25322536
}
25332537
}
25342538

0 commit comments

Comments
 (0)