Fix of #4889 (malfunctioning single instance detection on macOS):

This was hapenning because the datadir did not exist yet, which was interpreted as another instance running.
This commit is contained in:
Lukas Matena 2020-10-18 01:42:19 +02:00
parent 9fdaa1bdbe
commit a47e94ebd5

View file

@ -11,6 +11,7 @@
#include "boost/nowide/convert.hpp" #include "boost/nowide/convert.hpp"
#include <boost/log/trivial.hpp> #include <boost/log/trivial.hpp>
#include <boost/filesystem/operations.hpp>
#include <iostream> #include <iostream>
#include <unordered_map> #include <unordered_map>
#include <fcntl.h> #include <fcntl.h>
@ -136,6 +137,13 @@ namespace instance_check_internal
fl.l_whence = SEEK_SET; fl.l_whence = SEEK_SET;
fl.l_start = 0; fl.l_start = 0;
fl.l_len = 1; fl.l_len = 1;
if (! boost::filesystem::is_directory(path)) {
BOOST_LOG_TRIVIAL(debug) << "get_lock(): datadir does not exist yet, creating...";
if (! boost::filesystem::create_directories(path))
BOOST_LOG_TRIVIAL(debug) << "get_lock(): unable to create datadir !!!";
}
if ((fdlock = open(dest_dir.c_str(), O_WRONLY | O_CREAT, 0666)) == -1) if ((fdlock = open(dest_dir.c_str(), O_WRONLY | O_CREAT, 0666)) == -1)
return true; return true;