Skip to content

Commit

Permalink
In cache_manager if using temporary file check for its existance and …
Browse files Browse the repository at this point in the history
…if it exists try to generate different name
  • Loading branch information
Neloop committed May 5, 2018
1 parent fd293de commit 1ee38fc
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/fileman/cache_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,13 @@ void cache_manager::put_file(const std::string &src_name, const std::string &dst
{
fs::path source_file(src_name);
fs::path destination_file = caching_dir_ / dst_name;
fs::path destination_temp_file = caching_dir_ / (dst_name + "-" + helpers::random_alphanum_string(10));
fs::path destination_temp_file;

do {
// generate name and check it for existance, if exists... repeat
destination_temp_file = caching_dir_ / (dst_name + "-" + helpers::random_alphanum_string(20) + ".tmp");
} while (fs::exists(destination_temp_file));

logger_->debug("Copying file {} to cache with name {}", src_name, dst_name);

try {
Expand Down

0 comments on commit 1ee38fc

Please sign in to comment.