OmniSciDB  8a228a1076
file_delete.h File Reference

shared utility for the db server and string dictionary server to remove old files More...

+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void file_delete (std::atomic< bool > &program_is_running, const unsigned int wait_interval_seconds, const std::string base_path)
 

Detailed Description

shared utility for the db server and string dictionary server to remove old files

Author
micha.nosp@m.el@o.nosp@m.mnisc.nosp@m.i.co.nosp@m.m>

Definition in file file_delete.h.

Function Documentation

◆ file_delete()

void file_delete ( std::atomic< bool > &  program_is_running,
const unsigned int  wait_interval_seconds,
const std::string  base_path 
)

Definition at line 232 of file File.cpp.

References logger::ERROR, error_code, logger::INFO, and LOG.

Referenced by startMapdServer().

234  {
235  const auto wait_duration = std::chrono::seconds(wait_interval_seconds);
236  const boost::filesystem::path path(base_path);
237  while (program_is_running) {
238  using vec = std::vector<boost::filesystem::path>; // store paths,
239  vec v;
241 
242  // copy vector from iterator as was getting weird random errors if
243  // removed direct from iterator
244  copy(boost::filesystem::directory_iterator(path),
245  boost::filesystem::directory_iterator(),
246  back_inserter(v));
247  for (vec::const_iterator it(v.begin()); it != v.end(); ++it) {
248  std::string object_name(it->string());
249 
250  if (boost::algorithm::ends_with(object_name, "DELETE_ME")) {
251  LOG(INFO) << " removing object " << object_name;
252  boost::filesystem::remove_all(*it, ec);
253  if (ec.value() != boost::system::errc::success) {
254  LOG(ERROR) << "Failed to remove object " << object_name << " error was " << ec;
255  }
256  }
257  }
258 
259  std::this_thread::sleep_for(wait_duration);
260  }
261 }
#define LOG(tag)
Definition: Logger.h:188
const int8_t const int64_t const uint64_t const int32_t const int64_t int64_t uint32_t const int64_t int32_t * error_code
+ Here is the caller graph for this function: