OmniSciDB  72c90bc290
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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

Definition in file file_delete.h.

Function Documentation

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

Definition at line 272 of file File.cpp.

References gpu_enabled::copy(), logger::ERROR, report::error_code(), logger::INFO, and LOG.

Referenced by startHeavyDBServer().

274  {
275  const auto wait_duration = std::chrono::seconds(wait_interval_seconds);
276  const boost::filesystem::path path(base_path);
277  while (program_is_running) {
278  using vec = std::vector<boost::filesystem::path>; // store paths,
279  vec v;
281 
282  // copy vector from iterator as was getting weird random errors if
283  // removed direct from iterator
284  copy(boost::filesystem::directory_iterator(path),
285  boost::filesystem::directory_iterator(),
286  back_inserter(v));
287  for (vec::const_iterator it(v.begin()); it != v.end(); ++it) {
288  std::string object_name(it->string());
289 
290  if (boost::algorithm::ends_with(object_name, "DELETE_ME")) {
291  LOG(INFO) << " removing object " << object_name;
292  boost::filesystem::remove_all(*it, ec);
293  if (ec.value() != boost::system::errc::success) {
294  LOG(ERROR) << "Failed to remove object " << object_name << " error was " << ec;
295  }
296  }
297  }
298 
299  std::this_thread::sleep_for(wait_duration);
300  }
301 }
#define LOG(tag)
Definition: Logger.h:285
DEVICE auto copy(ARGS &&...args)
Definition: gpu_enabled.h:51
def error_code
Definition: report.py:244

+ Here is the call graph for this function:

+ Here is the caller graph for this function: