Always save temporary files in unique directory to ensure that all of them have different paths,

GitOrigin-RevId: 7113952a085f34a04eac38646f5a7a403bf9e9ba
This commit is contained in:
levlam 2020-01-06 01:31:28 +03:00
parent 8a1d035d1a
commit a6be36e7f2

View File

@ -739,12 +739,12 @@ Status HttpReader::open_temp_file(CSlice desired_file_name) {
TRY_RESULT(dir, realpath(tmp_dir, true)); TRY_RESULT(dir, realpath(tmp_dir, true));
CHECK(!dir.empty()); CHECK(!dir.empty());
/*
auto first_try = try_open_temp_file(dir, desired_file_name); auto first_try = try_open_temp_file(dir, desired_file_name);
if (first_try.is_ok()) { if (first_try.is_ok()) {
return Status::OK(); return Status::OK();
} }
*/
// Creation of new file with desired name has failed. Trying to create unique directory for it // Creation of new file with desired name has failed. Trying to create unique directory for it
TRY_RESULT(directory, mkdtemp(dir, TEMP_DIRECTORY_PREFIX)); TRY_RESULT(directory, mkdtemp(dir, TEMP_DIRECTORY_PREFIX));
auto second_try = try_open_temp_file(directory, desired_file_name); auto second_try = try_open_temp_file(directory, desired_file_name);