OmniSciDB  d2f719934e
 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

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

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 282 of file File.cpp.

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

Referenced by startMapdServer().

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

+ Here is the call graph for this function:

+ Here is the caller graph for this function: