Fix preprocessor failure to rename +<model> directory if /tmp is not on the same filesystem

Bug introduced in 0c755460, that manifested on the Gitlab runners.
issue#70
Sébastien Villemot 2019-09-11 17:03:37 +02:00
parent 2c6fa34a1f
commit bad0c3cf27
No known key found for this signature in database
GPG Key ID: 2CECE9350ECEBE4A
2 changed files with 5 additions and 3 deletions

View File

@ -853,7 +853,9 @@ ModFile::writeOutputFiles(const string &basename, bool clear_all, bool clear_glo
macOS), if we directly remove the "+" subdirectory, then the macOS), if we directly remove the "+" subdirectory, then the
preprocessor is not able to recreate it afterwards (presumably because preprocessor is not able to recreate it afterwards (presumably because
MATLAB maintains some sort of lock on it). The workaround is to rename MATLAB maintains some sort of lock on it). The workaround is to rename
it before deleting it. */ it before deleting it (the renaming must occur in the same directory,
otherwise it may file if the destination is not on the same
filesystem). */
if (filesystem::exists("+" + basename)) if (filesystem::exists("+" + basename))
{ {
auto tmp = unique_path(); auto tmp = unique_path();
@ -1582,7 +1584,7 @@ ModFile::unique_path()
string rand_str(rand_length, '\0'); string rand_str(rand_length, '\0');
for (auto &dis : rand_str) for (auto &dis : rand_str)
dis = possible_characters[distribution(generator)]; dis = possible_characters[distribution(generator)];
path = filesystem::temp_directory_path() / rand_str; path = rand_str;
} }
while (filesystem::exists(path)); while (filesystem::exists(path));

View File

@ -131,7 +131,7 @@ private:
void writeJsonComputingPassOutput(const string &basename, JsonFileOutputType json_output_mode, bool jsonderivsimple) const; void writeJsonComputingPassOutput(const string &basename, JsonFileOutputType json_output_mode, bool jsonderivsimple) const;
void writeJsonFileHelper(const string &fname, ostringstream &output) const; void writeJsonFileHelper(const string &fname, ostringstream &output) const;
vector<expr_t> pac_growth; vector<expr_t> pac_growth;
/* Generate a random temporary path. Equivalent to /* Generate a random temporary path, in the current directory. Equivalent to
boost::filesystem::unique_path(). Both are insecure, but currently there boost::filesystem::unique_path(). Both are insecure, but currently there
is no better portable solution. Maybe in a later C++ standard? */ is no better portable solution. Maybe in a later C++ standard? */
static filesystem::path unique_path(); static filesystem::path unique_path();