mirror of
https://github.com/XRPLF/rippled.git
synced 2026-04-29 15:37:57 +00:00
Compare commits
14 Commits
bthomee/no
...
copilot/re
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2e0ea38d7d | ||
|
|
aa1f84e226 | ||
|
|
ae7076c054 | ||
|
|
9a221d1291 | ||
|
|
5e6d8a4692 | ||
|
|
11c7d912f6 | ||
|
|
b7d6cdf713 | ||
|
|
193ddcbfac | ||
|
|
3a70d9dfba | ||
|
|
03e8a68670 | ||
|
|
28143d74af | ||
|
|
ff4c538a9f | ||
|
|
9fe94c47c3 | ||
|
|
3f307f8128 |
@@ -1,6 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <boost/filesystem.hpp>
|
#include <filesystem>
|
||||||
|
|
||||||
namespace xrpl {
|
namespace xrpl {
|
||||||
|
|
||||||
@@ -12,6 +12,6 @@ namespace xrpl {
|
|||||||
@throws runtime_error
|
@throws runtime_error
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
extractTarLz4(boost::filesystem::path const& src, boost::filesystem::path const& dst);
|
extractTarLz4(std::filesystem::path const& src, std::filesystem::path const& dst);
|
||||||
|
|
||||||
} // namespace xrpl
|
} // namespace xrpl
|
||||||
|
|||||||
@@ -1,22 +1,22 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <boost/filesystem.hpp>
|
#include <filesystem>
|
||||||
#include <boost/system/error_code.hpp>
|
|
||||||
|
|
||||||
#include <optional>
|
#include <optional>
|
||||||
|
#include <string>
|
||||||
|
#include <system_error>
|
||||||
|
|
||||||
namespace xrpl {
|
namespace xrpl {
|
||||||
|
|
||||||
std::string
|
std::string
|
||||||
getFileContents(
|
getFileContents(
|
||||||
boost::system::error_code& ec,
|
std::error_code& ec,
|
||||||
boost::filesystem::path const& sourcePath,
|
std::filesystem::path const& sourcePath,
|
||||||
std::optional<std::size_t> maxSize = std::nullopt);
|
std::optional<std::size_t> maxSize = std::nullopt);
|
||||||
|
|
||||||
void
|
void
|
||||||
writeFileContents(
|
writeFileContents(
|
||||||
boost::system::error_code& ec,
|
std::error_code& ec,
|
||||||
boost::filesystem::path const& destPath,
|
std::filesystem::path const& destPath,
|
||||||
std::string const& contents);
|
std::string const& contents);
|
||||||
|
|
||||||
} // namespace xrpl
|
} // namespace xrpl
|
||||||
|
|||||||
@@ -4,8 +4,8 @@
|
|||||||
#include <xrpl/beast/utility/Journal.h>
|
#include <xrpl/beast/utility/Journal.h>
|
||||||
|
|
||||||
#include <boost/beast/core/string.hpp>
|
#include <boost/beast/core/string.hpp>
|
||||||
#include <boost/filesystem.hpp>
|
|
||||||
|
|
||||||
|
#include <filesystem>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
@@ -88,7 +88,7 @@ private:
|
|||||||
@return `true` if the file was opened.
|
@return `true` if the file was opened.
|
||||||
*/
|
*/
|
||||||
bool
|
bool
|
||||||
open(boost::filesystem::path const& path);
|
open(std::filesystem::path const& path);
|
||||||
|
|
||||||
/** Close and re-open the system file associated with the log
|
/** Close and re-open the system file associated with the log
|
||||||
This assists in interoperating with external log management tools.
|
This assists in interoperating with external log management tools.
|
||||||
@@ -130,7 +130,7 @@ private:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
std::unique_ptr<std::ofstream> m_stream;
|
std::unique_ptr<std::ofstream> m_stream;
|
||||||
boost::filesystem::path m_path;
|
std::filesystem::path m_path;
|
||||||
};
|
};
|
||||||
|
|
||||||
std::mutex mutable mutex_;
|
std::mutex mutable mutex_;
|
||||||
@@ -149,7 +149,7 @@ public:
|
|||||||
virtual ~Logs() = default;
|
virtual ~Logs() = default;
|
||||||
|
|
||||||
bool
|
bool
|
||||||
open(boost::filesystem::path const& pathToLogFile);
|
open(std::filesystem::path const& pathToLogFile);
|
||||||
|
|
||||||
beast::Journal::Sink&
|
beast::Journal::Sink&
|
||||||
get(std::string const& name);
|
get(std::string const& name);
|
||||||
|
|||||||
@@ -6,10 +6,10 @@
|
|||||||
|
|
||||||
#include <xrpl/beast/unit_test/runner.h>
|
#include <xrpl/beast/unit_test/runner.h>
|
||||||
|
|
||||||
#include <boost/filesystem.hpp>
|
|
||||||
#include <boost/lexical_cast.hpp>
|
#include <boost/lexical_cast.hpp>
|
||||||
#include <boost/throw_exception.hpp>
|
#include <boost/throw_exception.hpp>
|
||||||
|
|
||||||
|
#include <filesystem>
|
||||||
#include <ostream>
|
#include <ostream>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <string>
|
#include <string>
|
||||||
@@ -25,7 +25,7 @@ make_reason(String const& reason, char const* file, int line)
|
|||||||
std::string s(reason);
|
std::string s(reason);
|
||||||
if (!s.empty())
|
if (!s.empty())
|
||||||
s.append(": ");
|
s.append(": ");
|
||||||
namespace fs = boost::filesystem;
|
namespace fs = std::filesystem;
|
||||||
s.append(fs::path{file}.filename().string());
|
s.append(fs::path{file}.filename().string());
|
||||||
s.append("(");
|
s.append("(");
|
||||||
s.append(boost::lexical_cast<std::string>(line));
|
s.append(boost::lexical_cast<std::string>(line));
|
||||||
|
|||||||
@@ -1,8 +1,11 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <boost/filesystem.hpp>
|
#include <filesystem>
|
||||||
|
#include <iomanip>
|
||||||
|
#include <random>
|
||||||
|
#include <sstream>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <system_error>
|
||||||
|
|
||||||
namespace beast {
|
namespace beast {
|
||||||
|
|
||||||
@@ -13,7 +16,7 @@ namespace beast {
|
|||||||
*/
|
*/
|
||||||
class temp_dir
|
class temp_dir
|
||||||
{
|
{
|
||||||
boost::filesystem::path path_;
|
std::filesystem::path path_;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
#if !GENERATING_DOCS
|
#if !GENERATING_DOCS
|
||||||
@@ -25,20 +28,30 @@ public:
|
|||||||
/// Construct a temporary directory.
|
/// Construct a temporary directory.
|
||||||
temp_dir()
|
temp_dir()
|
||||||
{
|
{
|
||||||
auto const dir = boost::filesystem::temp_directory_path();
|
auto const dir = std::filesystem::temp_directory_path();
|
||||||
do
|
std::random_device rd;
|
||||||
|
constexpr std::size_t maxAttempts = 100;
|
||||||
|
for (std::size_t attempt = 0; attempt < maxAttempts; ++attempt)
|
||||||
{
|
{
|
||||||
path_ = dir / boost::filesystem::unique_path();
|
std::error_code ec;
|
||||||
} while (boost::filesystem::exists(path_));
|
std::ostringstream oss;
|
||||||
boost::filesystem::create_directory(path_);
|
oss << std::hex << std::setfill('0') << std::setw(8) << rd() << std::setw(8) << rd();
|
||||||
|
path_ = dir / oss.str();
|
||||||
|
if (!std::filesystem::exists(path_, ec) && !ec)
|
||||||
|
break;
|
||||||
|
path_.clear();
|
||||||
|
}
|
||||||
|
if (path_.empty())
|
||||||
|
throw std::runtime_error("Unable to generate a unique temporary directory path");
|
||||||
|
std::filesystem::create_directory(path_);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Destroy a temporary directory.
|
/// Destroy a temporary directory.
|
||||||
~temp_dir()
|
~temp_dir()
|
||||||
{
|
{
|
||||||
// use non-throwing calls in the destructor
|
// use non-throwing calls in the destructor
|
||||||
boost::system::error_code ec;
|
std::error_code ec;
|
||||||
boost::filesystem::remove_all(path_, ec);
|
std::filesystem::remove_all(path_, ec);
|
||||||
// TODO: warn/notify if ec set ?
|
// TODO: warn/notify if ec set ?
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,10 +4,9 @@
|
|||||||
#include <xrpl/core/JobTypes.h>
|
#include <xrpl/core/JobTypes.h>
|
||||||
#include <xrpl/json/json_value.h>
|
#include <xrpl/json/json_value.h>
|
||||||
|
|
||||||
#include <boost/filesystem.hpp>
|
|
||||||
|
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
#include <filesystem>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <string>
|
#include <string>
|
||||||
@@ -43,7 +42,7 @@ public:
|
|||||||
*/
|
*/
|
||||||
struct Setup
|
struct Setup
|
||||||
{
|
{
|
||||||
boost::filesystem::path perfLog;
|
std::filesystem::path perfLog;
|
||||||
// log_interval is in milliseconds to support faster testing.
|
// log_interval is in milliseconds to support faster testing.
|
||||||
milliseconds logInterval{seconds(1)};
|
milliseconds logInterval{seconds(1)};
|
||||||
};
|
};
|
||||||
@@ -148,7 +147,7 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
PerfLog::Setup
|
PerfLog::Setup
|
||||||
setup_PerfLog(Section const& section, boost::filesystem::path const& configDir);
|
setup_PerfLog(Section const& section, std::filesystem::path const& configDir);
|
||||||
|
|
||||||
std::unique_ptr<PerfLog>
|
std::unique_ptr<PerfLog>
|
||||||
make_PerfLog(
|
make_PerfLog(
|
||||||
|
|||||||
@@ -6,8 +6,7 @@
|
|||||||
#include <xrpl/rdb/DBInit.h>
|
#include <xrpl/rdb/DBInit.h>
|
||||||
#include <xrpl/rdb/SociDB.h>
|
#include <xrpl/rdb/SociDB.h>
|
||||||
|
|
||||||
#include <boost/filesystem/path.hpp>
|
#include <filesystem>
|
||||||
|
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
#include <optional>
|
#include <optional>
|
||||||
#include <string>
|
#include <string>
|
||||||
@@ -72,7 +71,7 @@ public:
|
|||||||
|
|
||||||
StartUpType startUp = StartUpType::Normal;
|
StartUpType startUp = StartUpType::Normal;
|
||||||
bool standAlone = false;
|
bool standAlone = false;
|
||||||
boost::filesystem::path dataDir;
|
std::filesystem::path dataDir;
|
||||||
// Indicates whether or not to return the `globalPragma`
|
// Indicates whether or not to return the `globalPragma`
|
||||||
// from commonPragma()
|
// from commonPragma()
|
||||||
bool useGlobalPragma = false;
|
bool useGlobalPragma = false;
|
||||||
@@ -135,7 +134,7 @@ public:
|
|||||||
|
|
||||||
template <std::size_t N, std::size_t M>
|
template <std::size_t N, std::size_t M>
|
||||||
DatabaseCon(
|
DatabaseCon(
|
||||||
boost::filesystem::path const& dataDir,
|
std::filesystem::path const& dataDir,
|
||||||
std::string const& dbName,
|
std::string const& dbName,
|
||||||
std::array<std::string, N> const& pragma,
|
std::array<std::string, N> const& pragma,
|
||||||
std::array<char const*, M> const& initSQL,
|
std::array<char const*, M> const& initSQL,
|
||||||
@@ -147,7 +146,7 @@ public:
|
|||||||
// Use this constructor to setup checkpointing
|
// Use this constructor to setup checkpointing
|
||||||
template <std::size_t N, std::size_t M>
|
template <std::size_t N, std::size_t M>
|
||||||
DatabaseCon(
|
DatabaseCon(
|
||||||
boost::filesystem::path const& dataDir,
|
std::filesystem::path const& dataDir,
|
||||||
std::string const& dbName,
|
std::string const& dbName,
|
||||||
std::array<std::string, N> const& pragma,
|
std::array<std::string, N> const& pragma,
|
||||||
std::array<char const*, M> const& initSQL,
|
std::array<char const*, M> const& initSQL,
|
||||||
@@ -182,7 +181,7 @@ private:
|
|||||||
|
|
||||||
template <std::size_t N, std::size_t M>
|
template <std::size_t N, std::size_t M>
|
||||||
DatabaseCon(
|
DatabaseCon(
|
||||||
boost::filesystem::path const& pPath,
|
std::filesystem::path const& pPath,
|
||||||
std::vector<std::string> const* commonPragma,
|
std::vector<std::string> const* commonPragma,
|
||||||
std::array<std::string, N> const& pragma,
|
std::array<std::string, N> const& pragma,
|
||||||
std::array<char const*, M> const& initSQL,
|
std::array<char const*, M> const& initSQL,
|
||||||
|
|||||||
@@ -10,7 +10,6 @@
|
|||||||
#include <xrpl/protocol/TxSearched.h>
|
#include <xrpl/protocol/TxSearched.h>
|
||||||
#include <xrpl/rdb/DatabaseCon.h>
|
#include <xrpl/rdb/DatabaseCon.h>
|
||||||
|
|
||||||
#include <boost/filesystem.hpp>
|
|
||||||
#include <boost/variant.hpp>
|
#include <boost/variant.hpp>
|
||||||
|
|
||||||
namespace xrpl {
|
namespace xrpl {
|
||||||
|
|||||||
@@ -4,8 +4,6 @@
|
|||||||
#include <xrpl/rdb/DatabaseCon.h>
|
#include <xrpl/rdb/DatabaseCon.h>
|
||||||
#include <xrpl/server/Manifest.h>
|
#include <xrpl/server/Manifest.h>
|
||||||
|
|
||||||
#include <boost/filesystem.hpp>
|
|
||||||
|
|
||||||
namespace xrpl {
|
namespace xrpl {
|
||||||
|
|
||||||
struct SavedState
|
struct SavedState
|
||||||
|
|||||||
@@ -2,20 +2,18 @@
|
|||||||
|
|
||||||
#include <xrpl/basics/contract.h>
|
#include <xrpl/basics/contract.h>
|
||||||
|
|
||||||
#include <boost/filesystem/operations.hpp>
|
|
||||||
#include <boost/filesystem/path.hpp>
|
|
||||||
|
|
||||||
#include <archive.h>
|
#include <archive.h>
|
||||||
#include <archive_entry.h>
|
#include <archive_entry.h>
|
||||||
|
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
|
#include <filesystem>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
|
|
||||||
namespace xrpl {
|
namespace xrpl {
|
||||||
|
|
||||||
void
|
void
|
||||||
extractTarLz4(boost::filesystem::path const& src, boost::filesystem::path const& dst)
|
extractTarLz4(std::filesystem::path const& src, std::filesystem::path const& dst)
|
||||||
{
|
{
|
||||||
if (!is_regular_file(src))
|
if (!is_regular_file(src))
|
||||||
Throw<std::runtime_error>("Invalid source file");
|
Throw<std::runtime_error>("Invalid source file");
|
||||||
|
|||||||
@@ -1,29 +1,24 @@
|
|||||||
#include <xrpl/basics/FileUtilities.h>
|
#include <xrpl/basics/FileUtilities.h>
|
||||||
|
|
||||||
#include <boost/filesystem/operations.hpp>
|
|
||||||
#include <boost/filesystem/path.hpp>
|
|
||||||
#include <boost/system/detail/errc.hpp>
|
|
||||||
#include <boost/system/detail/error_code.hpp>
|
|
||||||
#include <boost/system/errc.hpp>
|
|
||||||
|
|
||||||
#include <cerrno>
|
#include <cerrno>
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
|
#include <filesystem>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <ios>
|
#include <ios>
|
||||||
#include <iterator>
|
#include <iterator>
|
||||||
#include <optional>
|
#include <optional>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <system_error>
|
||||||
|
|
||||||
namespace xrpl {
|
namespace xrpl {
|
||||||
|
|
||||||
std::string
|
std::string
|
||||||
getFileContents(
|
getFileContents(
|
||||||
boost::system::error_code& ec,
|
std::error_code& ec,
|
||||||
boost::filesystem::path const& sourcePath,
|
std::filesystem::path const& sourcePath,
|
||||||
std::optional<std::size_t> maxSize)
|
std::optional<std::size_t> maxSize)
|
||||||
{
|
{
|
||||||
using namespace boost::filesystem;
|
using namespace std::filesystem;
|
||||||
using namespace boost::system::errc;
|
|
||||||
|
|
||||||
path const fullPath{canonical(sourcePath, ec)};
|
path const fullPath{canonical(sourcePath, ec)};
|
||||||
if (ec)
|
if (ec)
|
||||||
@@ -32,15 +27,15 @@ getFileContents(
|
|||||||
if (maxSize && (file_size(fullPath, ec) > *maxSize || ec))
|
if (maxSize && (file_size(fullPath, ec) > *maxSize || ec))
|
||||||
{
|
{
|
||||||
if (!ec)
|
if (!ec)
|
||||||
ec = make_error_code(file_too_large);
|
ec = make_error_code(std::errc::file_too_large);
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
std::ifstream fileStream(fullPath.string(), std::ios::in);
|
std::ifstream fileStream(fullPath, std::ios::in);
|
||||||
|
|
||||||
if (!fileStream)
|
if (!fileStream)
|
||||||
{
|
{
|
||||||
ec = make_error_code(static_cast<errc_t>(errno));
|
ec.assign(errno, std::generic_category());
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -49,7 +44,7 @@ getFileContents(
|
|||||||
|
|
||||||
if (fileStream.bad())
|
if (fileStream.bad())
|
||||||
{
|
{
|
||||||
ec = make_error_code(static_cast<errc_t>(errno));
|
ec.assign(errno, std::generic_category());
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -58,18 +53,15 @@ getFileContents(
|
|||||||
|
|
||||||
void
|
void
|
||||||
writeFileContents(
|
writeFileContents(
|
||||||
boost::system::error_code& ec,
|
std::error_code& ec,
|
||||||
boost::filesystem::path const& destPath,
|
std::filesystem::path const& destPath,
|
||||||
std::string const& contents)
|
std::string const& contents)
|
||||||
{
|
{
|
||||||
using namespace boost::filesystem;
|
std::ofstream fileStream(destPath, std::ios::out | std::ios::trunc);
|
||||||
using namespace boost::system::errc;
|
|
||||||
|
|
||||||
std::ofstream fileStream(destPath.string(), std::ios::out | std::ios::trunc);
|
|
||||||
|
|
||||||
if (!fileStream)
|
if (!fileStream)
|
||||||
{
|
{
|
||||||
ec = make_error_code(static_cast<errc_t>(errno));
|
ec.assign(errno, std::generic_category());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -77,7 +69,7 @@ writeFileContents(
|
|||||||
|
|
||||||
if (fileStream.bad())
|
if (fileStream.bad())
|
||||||
{
|
{
|
||||||
ec = make_error_code(static_cast<errc_t>(errno));
|
ec.assign(errno, std::generic_category());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,10 +5,10 @@
|
|||||||
#include <xrpl/beast/utility/instrumentation.h>
|
#include <xrpl/beast/utility/instrumentation.h>
|
||||||
|
|
||||||
#include <boost/algorithm/string/predicate.hpp>
|
#include <boost/algorithm/string/predicate.hpp>
|
||||||
#include <boost/filesystem/path.hpp>
|
|
||||||
|
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
#include <filesystem>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
@@ -53,7 +53,7 @@ Logs::File::isOpen() const noexcept
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
Logs::File::open(boost::filesystem::path const& path)
|
Logs::File::open(std::filesystem::path const& path)
|
||||||
{
|
{
|
||||||
close();
|
close();
|
||||||
|
|
||||||
@@ -112,7 +112,7 @@ Logs::Logs(beast::severities::Severity thresh) : thresh_(thresh) // default sev
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
Logs::open(boost::filesystem::path const& pathToLogFile)
|
Logs::open(std::filesystem::path const& pathToLogFile)
|
||||||
{
|
{
|
||||||
return file_.open(pathToLogFile);
|
return file_.open(pathToLogFile);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,8 +15,6 @@
|
|||||||
#include <xrpl/nodestore/detail/EncodedBlob.h>
|
#include <xrpl/nodestore/detail/EncodedBlob.h>
|
||||||
#include <xrpl/nodestore/detail/codec.h>
|
#include <xrpl/nodestore/detail/codec.h>
|
||||||
|
|
||||||
#include <boost/filesystem/operations.hpp>
|
|
||||||
#include <boost/filesystem/path.hpp>
|
|
||||||
#include <boost/system/detail/errc.hpp>
|
#include <boost/system/detail/errc.hpp>
|
||||||
|
|
||||||
#include <nudb/context.hpp>
|
#include <nudb/context.hpp>
|
||||||
@@ -35,12 +33,14 @@
|
|||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <exception>
|
#include <exception>
|
||||||
|
#include <filesystem>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <optional>
|
#include <optional>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <system_error>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
@@ -131,7 +131,7 @@ public:
|
|||||||
void
|
void
|
||||||
open(bool createIfMissing, uint64_t appType, uint64_t uid, uint64_t salt) override
|
open(bool createIfMissing, uint64_t appType, uint64_t uid, uint64_t salt) override
|
||||||
{
|
{
|
||||||
using namespace boost::filesystem;
|
using namespace std::filesystem;
|
||||||
if (db_.is_open())
|
if (db_.is_open())
|
||||||
{
|
{
|
||||||
// LCOV_EXCL_START
|
// LCOV_EXCL_START
|
||||||
@@ -194,11 +194,12 @@ public:
|
|||||||
|
|
||||||
if (deletePath_)
|
if (deletePath_)
|
||||||
{
|
{
|
||||||
boost::filesystem::remove_all(name_, ec);
|
std::error_code fsec;
|
||||||
if (ec)
|
std::filesystem::remove_all(name_, fsec);
|
||||||
|
if (fsec)
|
||||||
{
|
{
|
||||||
JLOG(j_.fatal())
|
JLOG(j_.fatal()) << "Filesystem remove_all of " << name_
|
||||||
<< "Filesystem remove_all of " << name_ << " failed with: " << ec.message();
|
<< " failed with: " << fsec.message();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -374,7 +375,7 @@ private:
|
|||||||
static std::size_t
|
static std::size_t
|
||||||
parseBlockSize(std::string const& name, Section const& keyValues, beast::Journal journal)
|
parseBlockSize(std::string const& name, Section const& keyValues, beast::Journal journal)
|
||||||
{
|
{
|
||||||
using namespace boost::filesystem;
|
using namespace std::filesystem;
|
||||||
auto const folder = path(name);
|
auto const folder = path(name);
|
||||||
auto const kp = (folder / "nudb.key").string();
|
auto const kp = (folder / "nudb.key").string();
|
||||||
|
|
||||||
|
|||||||
@@ -8,9 +8,6 @@
|
|||||||
#include <xrpl/nodestore/Scheduler.h>
|
#include <xrpl/nodestore/Scheduler.h>
|
||||||
#include <xrpl/nodestore/Types.h>
|
#include <xrpl/nodestore/Types.h>
|
||||||
|
|
||||||
#include <boost/filesystem/operations.hpp>
|
|
||||||
#include <boost/filesystem/path.hpp>
|
|
||||||
|
|
||||||
#include <rocksdb/advanced_options.h>
|
#include <rocksdb/advanced_options.h>
|
||||||
#include <rocksdb/cache.h>
|
#include <rocksdb/cache.h>
|
||||||
#include <rocksdb/compression_type.h>
|
#include <rocksdb/compression_type.h>
|
||||||
@@ -26,6 +23,7 @@
|
|||||||
|
|
||||||
#include <bit>
|
#include <bit>
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
|
#include <filesystem>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
#include <string>
|
#include <string>
|
||||||
@@ -265,8 +263,8 @@ public:
|
|||||||
m_db.reset();
|
m_db.reset();
|
||||||
if (m_deletePath)
|
if (m_deletePath)
|
||||||
{
|
{
|
||||||
boost::filesystem::path const dir = m_name;
|
std::filesystem::path const dir = m_name;
|
||||||
boost::filesystem::remove_all(dir);
|
std::filesystem::remove_all(dir);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,13 +4,11 @@
|
|||||||
#include <xrpl/core/JobQueue.h>
|
#include <xrpl/core/JobQueue.h>
|
||||||
#include <xrpl/core/ServiceRegistry.h>
|
#include <xrpl/core/ServiceRegistry.h>
|
||||||
|
|
||||||
#include <boost/filesystem/operations.hpp>
|
|
||||||
#include <boost/filesystem/path.hpp>
|
|
||||||
|
|
||||||
#include <soci/blob.h>
|
#include <soci/blob.h>
|
||||||
|
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
#include <filesystem>
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
#include <string>
|
#include <string>
|
||||||
@@ -44,8 +42,8 @@ getSociSqliteInit(std::string const& name, std::string const& dir, std::string c
|
|||||||
Throw<std::runtime_error>(
|
Throw<std::runtime_error>(
|
||||||
"Sqlite databases must specify a dir and a name. Name: " + name + " Dir: " + dir);
|
"Sqlite databases must specify a dir and a name. Name: " + name + " Dir: " + dir);
|
||||||
}
|
}
|
||||||
boost::filesystem::path file(dir);
|
std::filesystem::path file(dir);
|
||||||
if (is_directory(file))
|
if (std::filesystem::is_directory(file))
|
||||||
file /= name + ext;
|
file /= name + ext;
|
||||||
return file.string();
|
return file.string();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,13 +5,12 @@
|
|||||||
#include <xrpl/rdb/DBInit.h>
|
#include <xrpl/rdb/DBInit.h>
|
||||||
#include <xrpl/rdb/DatabaseCon.h>
|
#include <xrpl/rdb/DatabaseCon.h>
|
||||||
|
|
||||||
#include <boost/filesystem/operations.hpp>
|
|
||||||
#include <boost/filesystem/path.hpp>
|
|
||||||
#include <boost/format.hpp> // IWYU pragma: keep
|
#include <boost/format.hpp> // IWYU pragma: keep
|
||||||
|
|
||||||
#include <soci/into.h>
|
#include <soci/into.h>
|
||||||
|
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
#include <filesystem>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
@@ -20,7 +19,7 @@ namespace xrpl {
|
|||||||
bool
|
bool
|
||||||
doVacuumDB(DatabaseCon::Setup const& setup, beast::Journal j)
|
doVacuumDB(DatabaseCon::Setup const& setup, beast::Journal j)
|
||||||
{
|
{
|
||||||
boost::filesystem::path const dbPath = setup.dataDir / TxDBName;
|
std::filesystem::path const dbPath = setup.dataDir / TxDBName;
|
||||||
|
|
||||||
uintmax_t const dbSize = file_size(dbPath);
|
uintmax_t const dbSize = file_size(dbPath);
|
||||||
XRPL_ASSERT(dbSize != static_cast<uintmax_t>(-1), "xrpl::doVacuumDB : file_size succeeded");
|
XRPL_ASSERT(dbSize != static_cast<uintmax_t>(-1), "xrpl::doVacuumDB : file_size succeeded");
|
||||||
|
|||||||
@@ -7,8 +7,6 @@
|
|||||||
#include <xrpl/proto/org/xrpl/rpc/v1/get_ledger.pb.h>
|
#include <xrpl/proto/org/xrpl/rpc/v1/get_ledger.pb.h>
|
||||||
#include <xrpl/proto/org/xrpl/rpc/v1/xrp_ledger.grpc.pb.h>
|
#include <xrpl/proto/org/xrpl/rpc/v1/xrp_ledger.grpc.pb.h>
|
||||||
|
|
||||||
#include <boost/filesystem/operations.hpp>
|
|
||||||
|
|
||||||
#include <grpcpp/client_context.h>
|
#include <grpcpp/client_context.h>
|
||||||
#include <grpcpp/create_channel.h>
|
#include <grpcpp/create_channel.h>
|
||||||
#include <grpcpp/grpcpp.h>
|
#include <grpcpp/grpcpp.h>
|
||||||
@@ -16,9 +14,14 @@
|
|||||||
#include <grpcpp/support/status.h>
|
#include <grpcpp/support/status.h>
|
||||||
|
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
|
#include <cstddef>
|
||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
#include <iomanip>
|
||||||
|
#include <ios>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
#include <random>
|
||||||
|
#include <sstream>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <string_view>
|
#include <string_view>
|
||||||
@@ -256,9 +259,23 @@ public:
|
|||||||
TemporaryTLSCertificates()
|
TemporaryTLSCertificates()
|
||||||
{
|
{
|
||||||
auto tmpDir = std::filesystem::temp_directory_path();
|
auto tmpDir = std::filesystem::temp_directory_path();
|
||||||
auto uniqueDirName =
|
std::random_device rd;
|
||||||
boost::filesystem::unique_path(std::string(kCERTS_DIR_PREFIX) + "%%%%%%%%");
|
constexpr std::size_t maxAttempts = 100;
|
||||||
tempDir_ = tmpDir / uniqueDirName.string();
|
for (std::size_t attempt = 0; attempt < maxAttempts; ++attempt)
|
||||||
|
{
|
||||||
|
std::error_code ec;
|
||||||
|
std::ostringstream oss;
|
||||||
|
oss << kCERTS_DIR_PREFIX << std::hex << std::setfill('0') << std::setw(8) << rd();
|
||||||
|
tempDir_ = tmpDir / oss.str();
|
||||||
|
if (!std::filesystem::exists(tempDir_, ec) && !ec)
|
||||||
|
break;
|
||||||
|
tempDir_.clear();
|
||||||
|
}
|
||||||
|
if (tempDir_.empty())
|
||||||
|
{
|
||||||
|
throw std::runtime_error(
|
||||||
|
"Unable to generate a unique temporary TLS certificate directory");
|
||||||
|
}
|
||||||
std::filesystem::create_directories(tempDir_);
|
std::filesystem::create_directories(tempDir_);
|
||||||
|
|
||||||
writeFile(tempDir_ / kCA_CERT_FILENAME, kCA_CERT_CONTENT);
|
writeFile(tempDir_ / kCA_CERT_FILENAME, kCA_CERT_CONTENT);
|
||||||
|
|||||||
@@ -18,16 +18,16 @@
|
|||||||
#include <xrpl/protocol/jss.h>
|
#include <xrpl/protocol/jss.h>
|
||||||
|
|
||||||
#include <boost/algorithm/string/erase.hpp>
|
#include <boost/algorithm/string/erase.hpp>
|
||||||
#include <boost/filesystem/operations.hpp>
|
|
||||||
#include <boost/system/detail/error_code.hpp>
|
|
||||||
|
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
|
#include <filesystem>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <ios>
|
#include <ios>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <optional>
|
#include <optional>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <system_error>
|
||||||
|
|
||||||
namespace xrpl {
|
namespace xrpl {
|
||||||
|
|
||||||
@@ -139,7 +139,7 @@ class LedgerLoad_test : public beast::unit_test::suite
|
|||||||
{
|
{
|
||||||
testcase("Load ledger: Bad Files");
|
testcase("Load ledger: Bad Files");
|
||||||
using namespace test::jtx;
|
using namespace test::jtx;
|
||||||
using namespace boost::filesystem;
|
using namespace std::filesystem;
|
||||||
|
|
||||||
// empty path
|
// empty path
|
||||||
except([&] {
|
except([&] {
|
||||||
@@ -161,8 +161,8 @@ class LedgerLoad_test : public beast::unit_test::suite
|
|||||||
});
|
});
|
||||||
|
|
||||||
// make a corrupted version of the ledger file (last 10 bytes removed).
|
// make a corrupted version of the ledger file (last 10 bytes removed).
|
||||||
boost::system::error_code ec;
|
std::error_code ec;
|
||||||
auto ledgerFileCorrupt = boost::filesystem::path{sd.dbPath} / "ledgerdata_bad.json";
|
auto ledgerFileCorrupt = std::filesystem::path{sd.dbPath} / "ledgerdata_bad.json";
|
||||||
copy_file(sd.ledgerFile, ledgerFileCorrupt, copy_options::overwrite_existing, ec);
|
copy_file(sd.ledgerFile, ledgerFileCorrupt, copy_options::overwrite_existing, ec);
|
||||||
if (!BEAST_EXPECTS(!ec, ec.message()))
|
if (!BEAST_EXPECTS(!ec, ec.message()))
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -21,14 +21,12 @@
|
|||||||
#include <xrpl/server/Manifest.h>
|
#include <xrpl/server/Manifest.h>
|
||||||
#include <xrpl/server/Wallet.h>
|
#include <xrpl/server/Wallet.h>
|
||||||
|
|
||||||
#include <boost/filesystem/operations.hpp>
|
|
||||||
#include <boost/filesystem/path.hpp>
|
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <array>
|
#include <array>
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <exception>
|
#include <exception>
|
||||||
|
#include <filesystem>
|
||||||
#include <limits>
|
#include <limits>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <optional>
|
#include <optional>
|
||||||
@@ -55,18 +53,18 @@ private:
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
cleanupDatabaseDir(boost::filesystem::path const& dbPath)
|
cleanupDatabaseDir(std::filesystem::path const& dbPath)
|
||||||
{
|
{
|
||||||
using namespace boost::filesystem;
|
using namespace std::filesystem;
|
||||||
if (!exists(dbPath) || !is_directory(dbPath) || !is_empty(dbPath))
|
if (!exists(dbPath) || !is_directory(dbPath) || !is_empty(dbPath))
|
||||||
return;
|
return;
|
||||||
remove(dbPath);
|
remove(dbPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
setupDatabaseDir(boost::filesystem::path const& dbPath)
|
setupDatabaseDir(std::filesystem::path const& dbPath)
|
||||||
{
|
{
|
||||||
using namespace boost::filesystem;
|
using namespace std::filesystem;
|
||||||
if (!exists(dbPath))
|
if (!exists(dbPath))
|
||||||
{
|
{
|
||||||
create_directory(dbPath);
|
create_directory(dbPath);
|
||||||
@@ -79,10 +77,10 @@ private:
|
|||||||
Throw<std::runtime_error>("Cannot create directory: " + dbPath.string());
|
Throw<std::runtime_error>("Cannot create directory: " + dbPath.string());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
static boost::filesystem::path
|
static std::filesystem::path
|
||||||
getDatabasePath()
|
getDatabasePath()
|
||||||
{
|
{
|
||||||
return boost::filesystem::current_path() / "manifest_test_databases";
|
return std::filesystem::current_path() / "manifest_test_databases";
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@@ -351,7 +349,7 @@ public:
|
|||||||
BEAST_EXPECT(loaded.revoked(pk));
|
BEAST_EXPECT(loaded.revoked(pk));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
boost::filesystem::remove(getDatabasePath() / boost::filesystem::path(dbName));
|
std::filesystem::remove(getDatabasePath() / std::filesystem::path(dbName));
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|||||||
@@ -21,10 +21,9 @@
|
|||||||
#include <xrpl/protocol/XRPAmount.h>
|
#include <xrpl/protocol/XRPAmount.h>
|
||||||
#include <xrpl/protocol/jss.h>
|
#include <xrpl/protocol/jss.h>
|
||||||
|
|
||||||
#include <boost/filesystem/path.hpp>
|
|
||||||
|
|
||||||
#include <atomic>
|
#include <atomic>
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
#include <filesystem>
|
||||||
#include <limits>
|
#include <limits>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
@@ -491,7 +490,7 @@ public:
|
|||||||
makeBackendRotating(jtx::Env& env, NodeStoreScheduler& scheduler, std::string path)
|
makeBackendRotating(jtx::Env& env, NodeStoreScheduler& scheduler, std::string path)
|
||||||
{
|
{
|
||||||
Section section{env.app().config().section(ConfigSection::nodeDatabase())};
|
Section section{env.app().config().section(ConfigSection::nodeDatabase())};
|
||||||
boost::filesystem::path newPath;
|
std::filesystem::path newPath;
|
||||||
|
|
||||||
if (!BEAST_EXPECT(path.size()))
|
if (!BEAST_EXPECT(path.size()))
|
||||||
return {};
|
return {};
|
||||||
|
|||||||
@@ -15,13 +15,12 @@
|
|||||||
#include <xrpl/protocol/jss.h>
|
#include <xrpl/protocol/jss.h>
|
||||||
|
|
||||||
#include <boost/algorithm/string/join.hpp>
|
#include <boost/algorithm/string/join.hpp>
|
||||||
#include <boost/filesystem/directory.hpp>
|
|
||||||
#include <boost/filesystem/operations.hpp>
|
|
||||||
#include <boost/range/adaptor/transformed.hpp>
|
#include <boost/range/adaptor/transformed.hpp>
|
||||||
|
|
||||||
#include <date/date.h>
|
#include <date/date.h>
|
||||||
|
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
|
#include <filesystem>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <ostream>
|
#include <ostream>
|
||||||
@@ -601,7 +600,7 @@ public:
|
|||||||
detail::default_effective_overlap,
|
detail::default_effective_overlap,
|
||||||
60 * 24}}); // max of 24 hours
|
60 * 24}}); // max of 24 hours
|
||||||
}
|
}
|
||||||
using namespace boost::filesystem;
|
using namespace std::filesystem;
|
||||||
for (auto const& file : directory_iterator(good.subdir()))
|
for (auto const& file : directory_iterator(good.subdir()))
|
||||||
{
|
{
|
||||||
remove_all(file);
|
remove_all(file);
|
||||||
|
|||||||
@@ -4,8 +4,7 @@
|
|||||||
#include <xrpl/basics/FileUtilities.h>
|
#include <xrpl/basics/FileUtilities.h>
|
||||||
#include <xrpl/beast/unit_test/suite.h>
|
#include <xrpl/beast/unit_test/suite.h>
|
||||||
|
|
||||||
#include <boost/system/detail/errc.hpp>
|
#include <system_error>
|
||||||
#include <boost/system/detail/error_code.hpp>
|
|
||||||
|
|
||||||
namespace xrpl {
|
namespace xrpl {
|
||||||
|
|
||||||
@@ -16,14 +15,13 @@ public:
|
|||||||
testGetFileContents()
|
testGetFileContents()
|
||||||
{
|
{
|
||||||
using namespace xrpl::detail;
|
using namespace xrpl::detail;
|
||||||
using namespace boost::system;
|
|
||||||
|
|
||||||
constexpr char const* expectedContents = "This file is very short. That's all we need.";
|
constexpr char const* expectedContents = "This file is very short. That's all we need.";
|
||||||
|
|
||||||
FileDirGuard const file(
|
FileDirGuard const file(
|
||||||
*this, "test_file", "test.txt", "This is temporary text that should get overwritten");
|
*this, "test_file", "test.txt", "This is temporary text that should get overwritten");
|
||||||
|
|
||||||
error_code ec;
|
std::error_code ec;
|
||||||
auto const path = file.file();
|
auto const path = file.file();
|
||||||
|
|
||||||
writeFileContents(ec, path, expectedContents);
|
writeFileContents(ec, path, expectedContents);
|
||||||
@@ -46,7 +44,7 @@ public:
|
|||||||
{
|
{
|
||||||
// Test with small max
|
// Test with small max
|
||||||
auto const bad = getFileContents(ec, path, 16);
|
auto const bad = getFileContents(ec, path, 16);
|
||||||
BEAST_EXPECT(ec && ec.value() == boost::system::errc::file_too_large);
|
BEAST_EXPECT(ec && ec == std::errc::file_too_large);
|
||||||
BEAST_EXPECT(bad.empty());
|
BEAST_EXPECT(bad.empty());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,14 +15,10 @@
|
|||||||
#include <xrpl/protocol/ErrorCodes.h>
|
#include <xrpl/protocol/ErrorCodes.h>
|
||||||
#include <xrpl/protocol/jss.h>
|
#include <xrpl/protocol/jss.h>
|
||||||
|
|
||||||
#include <boost/filesystem/file_status.hpp>
|
|
||||||
#include <boost/filesystem/operations.hpp>
|
|
||||||
#include <boost/filesystem/path.hpp>
|
|
||||||
#include <boost/system/detail/error_code.hpp>
|
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
#include <filesystem>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <ios>
|
#include <ios>
|
||||||
#include <iterator>
|
#include <iterator>
|
||||||
@@ -31,6 +27,7 @@
|
|||||||
#include <ostream>
|
#include <ostream>
|
||||||
#include <random>
|
#include <random>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <system_error>
|
||||||
#include <thread>
|
#include <thread>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
@@ -43,7 +40,7 @@ class PerfLog_test : public beast::unit_test::suite
|
|||||||
{
|
{
|
||||||
enum class WithFile : bool { no = false, yes = true };
|
enum class WithFile : bool { no = false, yes = true };
|
||||||
|
|
||||||
using path = boost::filesystem::path;
|
using path = std::filesystem::path;
|
||||||
|
|
||||||
// We're only using Env for its Journal. That Journal gives better
|
// We're only using Env for its Journal. That Journal gives better
|
||||||
// coverage in unit tests.
|
// coverage in unit tests.
|
||||||
@@ -66,14 +63,14 @@ class PerfLog_test : public beast::unit_test::suite
|
|||||||
// The error code is intentionally ignored: if the path doesn't
|
// The error code is intentionally ignored: if the path doesn't
|
||||||
// exist (the common case on a clean runner) remove_all returns
|
// exist (the common case on a clean runner) remove_all returns
|
||||||
// an error, and that's fine — there's nothing to clean up.
|
// an error, and that's fine — there's nothing to clean up.
|
||||||
using namespace boost::filesystem;
|
using namespace std::filesystem;
|
||||||
boost::system::error_code ec;
|
std::error_code ec;
|
||||||
remove_all(logDir(), ec);
|
remove_all(logDir(), ec);
|
||||||
}
|
}
|
||||||
|
|
||||||
~Fixture()
|
~Fixture()
|
||||||
{
|
{
|
||||||
using namespace boost::filesystem;
|
using namespace std::filesystem;
|
||||||
|
|
||||||
auto const dir{logDir()};
|
auto const dir{logDir()};
|
||||||
auto const file{logFile()};
|
auto const file{logFile()};
|
||||||
@@ -96,7 +93,7 @@ class PerfLog_test : public beast::unit_test::suite
|
|||||||
static path
|
static path
|
||||||
logDir()
|
logDir()
|
||||||
{
|
{
|
||||||
using namespace boost::filesystem;
|
using namespace std::filesystem;
|
||||||
return temp_directory_path() / "perf_log_test_dir";
|
return temp_directory_path() / "perf_log_test_dir";
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -129,7 +126,7 @@ class PerfLog_test : public beast::unit_test::suite
|
|||||||
static void
|
static void
|
||||||
wait()
|
wait()
|
||||||
{
|
{
|
||||||
using namespace boost::filesystem;
|
using namespace std::filesystem;
|
||||||
|
|
||||||
auto const path = logFile();
|
auto const path = logFile();
|
||||||
if (!exists(path))
|
if (!exists(path))
|
||||||
@@ -201,7 +198,7 @@ public:
|
|||||||
void
|
void
|
||||||
testFileCreation()
|
testFileCreation()
|
||||||
{
|
{
|
||||||
using namespace boost::filesystem;
|
using namespace std::filesystem;
|
||||||
|
|
||||||
{
|
{
|
||||||
// Verify a PerfLog creates its file when constructed.
|
// Verify a PerfLog creates its file when constructed.
|
||||||
@@ -256,22 +253,23 @@ public:
|
|||||||
|
|
||||||
// Construct and write protect a file to prevent PerfLog
|
// Construct and write protect a file to prevent PerfLog
|
||||||
// from creating its file.
|
// from creating its file.
|
||||||
boost::system::error_code ec;
|
std::error_code ec;
|
||||||
boost::filesystem::create_directories(fixture.logDir(), ec);
|
std::filesystem::create_directories(fixture.logDir(), ec);
|
||||||
if (!BEAST_EXPECT(!ec))
|
if (!BEAST_EXPECT(!ec))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
auto fileWriteable = [](boost::filesystem::path const& p) -> bool {
|
auto fileWriteable = [](std::filesystem::path const& p) -> bool {
|
||||||
return std::ofstream{p.c_str(), std::ios::out | std::ios::app}.is_open();
|
return std::ofstream{p.c_str(), std::ios::out | std::ios::app}.is_open();
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!BEAST_EXPECT(fileWriteable(fixture.logFile())))
|
if (!BEAST_EXPECT(fileWriteable(fixture.logFile())))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
boost::filesystem::permissions(
|
std::filesystem::permissions(
|
||||||
fixture.logFile(),
|
fixture.logFile(),
|
||||||
perms::remove_perms | perms::owner_write | perms::others_write |
|
std::filesystem::perms::owner_write | std::filesystem::perms::others_write |
|
||||||
perms::group_write);
|
std::filesystem::perms::group_write,
|
||||||
|
std::filesystem::perm_options::remove);
|
||||||
|
|
||||||
// If the test is running as root, then the write protect may have
|
// If the test is running as root, then the write protect may have
|
||||||
// no effect. Make sure write protect worked before proceeding.
|
// no effect. Make sure write protect worked before proceeding.
|
||||||
@@ -295,9 +293,11 @@ public:
|
|||||||
perfLog->stop();
|
perfLog->stop();
|
||||||
|
|
||||||
// Fix file permissions so the file can be cleaned up.
|
// Fix file permissions so the file can be cleaned up.
|
||||||
boost::filesystem::permissions(
|
std::filesystem::permissions(
|
||||||
fixture.logFile(),
|
fixture.logFile(),
|
||||||
perms::add_perms | perms::owner_write | perms::others_write | perms::group_write);
|
std::filesystem::perms::owner_write | std::filesystem::perms::others_write |
|
||||||
|
std::filesystem::perms::group_write,
|
||||||
|
std::filesystem::perm_options::add);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -962,7 +962,7 @@ public:
|
|||||||
// We can't fully test rotate because unit tests must run on Windows,
|
// We can't fully test rotate because unit tests must run on Windows,
|
||||||
// and Windows doesn't (may not?) support rotate. But at least call
|
// and Windows doesn't (may not?) support rotate. But at least call
|
||||||
// the interface and see that it doesn't crash.
|
// the interface and see that it doesn't crash.
|
||||||
using namespace boost::filesystem;
|
using namespace std::filesystem;
|
||||||
|
|
||||||
Fixture fixture{env_.app(), j_};
|
Fixture fixture{env_.app(), j_};
|
||||||
BEAST_EXPECT(!exists(fixture.logDir()));
|
BEAST_EXPECT(!exists(fixture.logDir()));
|
||||||
|
|||||||
@@ -10,7 +10,6 @@
|
|||||||
#include <xrpl/protocol/SystemParameters.h> // IWYU pragma: keep
|
#include <xrpl/protocol/SystemParameters.h> // IWYU pragma: keep
|
||||||
#include <xrpl/server/Port.h>
|
#include <xrpl/server/Port.h>
|
||||||
|
|
||||||
#include <boost/filesystem/operations.hpp>
|
|
||||||
#include <boost/format.hpp> // IWYU pragma: keep
|
#include <boost/format.hpp> // IWYU pragma: keep
|
||||||
#include <boost/format/free_funcs.hpp>
|
#include <boost/format/free_funcs.hpp>
|
||||||
#include <boost/lexical_cast/bad_lexical_cast.hpp>
|
#include <boost/lexical_cast/bad_lexical_cast.hpp>
|
||||||
@@ -20,6 +19,7 @@
|
|||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <exception>
|
#include <exception>
|
||||||
|
#include <filesystem>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <optional>
|
#include <optional>
|
||||||
#include <ostream>
|
#include <ostream>
|
||||||
@@ -179,7 +179,7 @@ public:
|
|||||||
[[nodiscard]] bool
|
[[nodiscard]] bool
|
||||||
dataDirExists() const
|
dataDirExists() const
|
||||||
{
|
{
|
||||||
return boost::filesystem::is_directory(dataDir_);
|
return std::filesystem::is_directory(dataDir_);
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]] bool
|
[[nodiscard]] bool
|
||||||
@@ -192,7 +192,7 @@ public:
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
using namespace boost::filesystem;
|
using namespace std::filesystem;
|
||||||
if (rmDataDir_)
|
if (rmDataDir_)
|
||||||
rmDir(dataDir_);
|
rmDir(dataDir_);
|
||||||
}
|
}
|
||||||
@@ -273,7 +273,7 @@ public:
|
|||||||
class Config_test final : public TestSuite
|
class Config_test final : public TestSuite
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
using path = boost::filesystem::path;
|
using path = std::filesystem::path;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void
|
void
|
||||||
@@ -309,7 +309,7 @@ port_wss_admin
|
|||||||
{
|
{
|
||||||
testcase("config_file");
|
testcase("config_file");
|
||||||
|
|
||||||
using namespace boost::filesystem;
|
using namespace std::filesystem;
|
||||||
auto const cwd = current_path();
|
auto const cwd = current_path();
|
||||||
|
|
||||||
// Test both config file names.
|
// Test both config file names.
|
||||||
@@ -425,7 +425,7 @@ port_wss_admin
|
|||||||
{
|
{
|
||||||
testcase("database_path");
|
testcase("database_path");
|
||||||
|
|
||||||
using namespace boost::filesystem;
|
using namespace std::filesystem;
|
||||||
{
|
{
|
||||||
boost::format cc("[database_path]\n%1%\n");
|
boost::format cc("[database_path]\n%1%\n");
|
||||||
|
|
||||||
@@ -601,7 +601,7 @@ main
|
|||||||
{
|
{
|
||||||
testcase("validators_file");
|
testcase("validators_file");
|
||||||
|
|
||||||
using namespace boost::filesystem;
|
using namespace std::filesystem;
|
||||||
{
|
{
|
||||||
// load should throw for missing specified validators file
|
// load should throw for missing specified validators file
|
||||||
boost::format cc("[validators_file]\n%1%\n");
|
boost::format cc("[validators_file]\n%1%\n");
|
||||||
|
|||||||
@@ -6,8 +6,6 @@
|
|||||||
#include <xrpl/rdb/SociDB.h>
|
#include <xrpl/rdb/SociDB.h>
|
||||||
|
|
||||||
#include <boost/algorithm/string/predicate.hpp>
|
#include <boost/algorithm/string/predicate.hpp>
|
||||||
#include <boost/filesystem/operations.hpp>
|
|
||||||
#include <boost/filesystem/path.hpp>
|
|
||||||
#include <boost/optional/optional.hpp>
|
#include <boost/optional/optional.hpp>
|
||||||
|
|
||||||
#include <soci/into.h>
|
#include <soci/into.h>
|
||||||
@@ -18,6 +16,7 @@
|
|||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <exception>
|
#include <exception>
|
||||||
|
#include <filesystem>
|
||||||
#include <iterator>
|
#include <iterator>
|
||||||
#include <limits>
|
#include <limits>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
@@ -30,7 +29,7 @@ class SociDB_test final : public TestSuite
|
|||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
static void
|
static void
|
||||||
setupSQLiteConfig(BasicConfig& config, boost::filesystem::path const& dbPath)
|
setupSQLiteConfig(BasicConfig& config, std::filesystem::path const& dbPath)
|
||||||
{
|
{
|
||||||
config.overwrite("sqdb", "backend", "sqlite");
|
config.overwrite("sqdb", "backend", "sqlite");
|
||||||
auto value = dbPath.string();
|
auto value = dbPath.string();
|
||||||
@@ -39,18 +38,18 @@ private:
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
cleanupDatabaseDir(boost::filesystem::path const& dbPath)
|
cleanupDatabaseDir(std::filesystem::path const& dbPath)
|
||||||
{
|
{
|
||||||
using namespace boost::filesystem;
|
using namespace std::filesystem;
|
||||||
if (!exists(dbPath) || !is_directory(dbPath) || !is_empty(dbPath))
|
if (!exists(dbPath) || !is_directory(dbPath) || !is_empty(dbPath))
|
||||||
return;
|
return;
|
||||||
remove(dbPath);
|
remove(dbPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
setupDatabaseDir(boost::filesystem::path const& dbPath)
|
setupDatabaseDir(std::filesystem::path const& dbPath)
|
||||||
{
|
{
|
||||||
using namespace boost::filesystem;
|
using namespace std::filesystem;
|
||||||
if (!exists(dbPath))
|
if (!exists(dbPath))
|
||||||
{
|
{
|
||||||
create_directory(dbPath);
|
create_directory(dbPath);
|
||||||
@@ -63,10 +62,10 @@ private:
|
|||||||
Throw<std::runtime_error>("Cannot create directory: " + dbPath.string());
|
Throw<std::runtime_error>("Cannot create directory: " + dbPath.string());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
static boost::filesystem::path
|
static std::filesystem::path
|
||||||
getDatabasePath()
|
getDatabasePath()
|
||||||
{
|
{
|
||||||
return boost::filesystem::current_path() / "socidb_test_databases";
|
return std::filesystem::current_path() / "socidb_test_databases";
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@@ -156,7 +155,7 @@ public:
|
|||||||
checkValues(s);
|
checkValues(s);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
namespace bfs = boost::filesystem;
|
namespace bfs = std::filesystem;
|
||||||
// Remove the database
|
// Remove the database
|
||||||
bfs::path const dbPath(sc.connectionString());
|
bfs::path const dbPath(sc.connectionString());
|
||||||
if (bfs::is_regular_file(dbPath))
|
if (bfs::is_regular_file(dbPath))
|
||||||
@@ -286,7 +285,7 @@ public:
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
namespace bfs = boost::filesystem;
|
namespace bfs = std::filesystem;
|
||||||
// Remove the database
|
// Remove the database
|
||||||
bfs::path const dbPath(sc.connectionString());
|
bfs::path const dbPath(sc.connectionString());
|
||||||
if (bfs::is_regular_file(dbPath))
|
if (bfs::is_regular_file(dbPath))
|
||||||
@@ -338,7 +337,7 @@ public:
|
|||||||
s << "SELECT LedgerSeq FROM Ledgers;", soci::into(ledgersLS);
|
s << "SELECT LedgerSeq FROM Ledgers;", soci::into(ledgersLS);
|
||||||
BEAST_EXPECT(ledgersLS.size() == numRows);
|
BEAST_EXPECT(ledgersLS.size() == numRows);
|
||||||
}
|
}
|
||||||
namespace bfs = boost::filesystem;
|
namespace bfs = std::filesystem;
|
||||||
// Remove the database
|
// Remove the database
|
||||||
bfs::path const dbPath(sc.connectionString());
|
bfs::path const dbPath(sc.connectionString());
|
||||||
if (bfs::is_regular_file(dbPath))
|
if (bfs::is_regular_file(dbPath))
|
||||||
|
|||||||
@@ -4,8 +4,7 @@
|
|||||||
|
|
||||||
#include <xrpl/basics/contract.h>
|
#include <xrpl/basics/contract.h>
|
||||||
|
|
||||||
#include <boost/filesystem.hpp>
|
#include <filesystem>
|
||||||
|
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
|
||||||
namespace xrpl::detail {
|
namespace xrpl::detail {
|
||||||
@@ -16,7 +15,7 @@ namespace xrpl::detail {
|
|||||||
class DirGuard
|
class DirGuard
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
using path = boost::filesystem::path;
|
using path = std::filesystem::path;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
path subDir_;
|
path subDir_;
|
||||||
@@ -43,7 +42,7 @@ public:
|
|||||||
DirGuard(beast::unit_test::suite& test, path subDir, bool useCounter = true)
|
DirGuard(beast::unit_test::suite& test, path subDir, bool useCounter = true)
|
||||||
: subDir_(std::move(subDir)), test_(test)
|
: subDir_(std::move(subDir)), test_(test)
|
||||||
{
|
{
|
||||||
using namespace boost::filesystem;
|
using namespace std::filesystem;
|
||||||
|
|
||||||
static auto subDirCounter = 0;
|
static auto subDirCounter = 0;
|
||||||
if (useCounter)
|
if (useCounter)
|
||||||
@@ -69,7 +68,7 @@ public:
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
using namespace boost::filesystem;
|
using namespace std::filesystem;
|
||||||
|
|
||||||
if (rmSubDir_)
|
if (rmSubDir_)
|
||||||
rmDir(subDir_);
|
rmDir(subDir_);
|
||||||
@@ -126,7 +125,7 @@ public:
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
using namespace boost::filesystem;
|
using namespace std::filesystem;
|
||||||
if (exists(file_))
|
if (exists(file_))
|
||||||
{
|
{
|
||||||
remove(file_);
|
remove(file_);
|
||||||
@@ -156,7 +155,7 @@ public:
|
|||||||
[[nodiscard]] bool
|
[[nodiscard]] bool
|
||||||
fileExists() const
|
fileExists() const
|
||||||
{
|
{
|
||||||
return boost::filesystem::exists(file_);
|
return std::filesystem::exists(file_);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -78,9 +78,11 @@
|
|||||||
#include <xrpl/protocol/ApiVersion.h>
|
#include <xrpl/protocol/ApiVersion.h>
|
||||||
#include <xrpl/protocol/BuildInfo.h>
|
#include <xrpl/protocol/BuildInfo.h>
|
||||||
#include <xrpl/protocol/Feature.h>
|
#include <xrpl/protocol/Feature.h>
|
||||||
|
#include <xrpl/protocol/Indexes.h>
|
||||||
#include <xrpl/protocol/Protocol.h>
|
#include <xrpl/protocol/Protocol.h>
|
||||||
#include <xrpl/protocol/STParsedJSON.h>
|
#include <xrpl/protocol/STParsedJSON.h>
|
||||||
#include <xrpl/protocol/Serializer.h>
|
#include <xrpl/protocol/Serializer.h>
|
||||||
|
#include <xrpl/protocol/SystemParameters.h>
|
||||||
#include <xrpl/protocol/jss.h>
|
#include <xrpl/protocol/jss.h>
|
||||||
#include <xrpl/rdb/DatabaseCon.h>
|
#include <xrpl/rdb/DatabaseCon.h>
|
||||||
#include <xrpl/resource/Charge.h>
|
#include <xrpl/resource/Charge.h>
|
||||||
|
|||||||
@@ -48,6 +48,7 @@
|
|||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <system_error>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
@@ -613,7 +614,7 @@ GRPCServerImpl::createServerCredentials()
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
boost::system::error_code ec;
|
std::error_code ec;
|
||||||
grpc::SslServerCredentialsOptions sslOpts;
|
grpc::SslServerCredentialsOptions sslOpts;
|
||||||
grpc::SslServerCredentialsOptions::PemKeyCertPair keyCertPair;
|
grpc::SslServerCredentialsOptions::PemKeyCertPair keyCertPair;
|
||||||
|
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
#include <xrpl/ledger/ReadView.h>
|
#include <xrpl/ledger/ReadView.h>
|
||||||
#include <xrpl/protocol/Feature.h>
|
#include <xrpl/protocol/Feature.h>
|
||||||
#include <xrpl/protocol/Fees.h>
|
#include <xrpl/protocol/Fees.h>
|
||||||
|
#include <xrpl/protocol/Protocol.h>
|
||||||
#include <xrpl/protocol/SField.h>
|
#include <xrpl/protocol/SField.h>
|
||||||
#include <xrpl/protocol/STTx.h>
|
#include <xrpl/protocol/STTx.h>
|
||||||
#include <xrpl/protocol/STValidation.h>
|
#include <xrpl/protocol/STValidation.h>
|
||||||
|
|||||||
@@ -24,19 +24,23 @@
|
|||||||
#include <xrpl/shamap/SHAMapTreeNode.h>
|
#include <xrpl/shamap/SHAMapTreeNode.h>
|
||||||
|
|
||||||
#include <boost/algorithm/string/predicate.hpp>
|
#include <boost/algorithm/string/predicate.hpp>
|
||||||
#include <boost/filesystem/directory.hpp>
|
|
||||||
#include <boost/filesystem/operations.hpp>
|
|
||||||
#include <boost/filesystem/path.hpp>
|
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
#include <cstddef>
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
#include <filesystem>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
|
#include <iomanip>
|
||||||
|
#include <ios>
|
||||||
#include <limits>
|
#include <limits>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
#include <optional>
|
#include <optional>
|
||||||
|
#include <random>
|
||||||
|
#include <sstream>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <system_error>
|
||||||
#include <thread>
|
#include <thread>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
@@ -368,11 +372,11 @@ void
|
|||||||
SHAMapStoreImp::dbPaths()
|
SHAMapStoreImp::dbPaths()
|
||||||
{
|
{
|
||||||
Section const section{app_.config().section(ConfigSection::nodeDatabase())};
|
Section const section{app_.config().section(ConfigSection::nodeDatabase())};
|
||||||
boost::filesystem::path dbPath = get(section, "path");
|
std::filesystem::path dbPath = get(section, "path");
|
||||||
|
|
||||||
if (boost::filesystem::exists(dbPath))
|
if (std::filesystem::exists(dbPath))
|
||||||
{
|
{
|
||||||
if (!boost::filesystem::is_directory(dbPath))
|
if (!std::filesystem::is_directory(dbPath))
|
||||||
{
|
{
|
||||||
journal_.error() << "node db path must be a directory. " << dbPath.string();
|
journal_.error() << "node db path must be a directory. " << dbPath.string();
|
||||||
Throw<std::runtime_error>("node db path must be a directory.");
|
Throw<std::runtime_error>("node db path must be a directory.");
|
||||||
@@ -380,7 +384,7 @@ SHAMapStoreImp::dbPaths()
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
boost::filesystem::create_directories(dbPath);
|
std::filesystem::create_directories(dbPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
SavedState state = state_db_.getState();
|
SavedState state = state_db_.getState();
|
||||||
@@ -391,8 +395,8 @@ SHAMapStoreImp::dbPaths()
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Check if configured "path" matches stored directory path
|
// Check if configured "path" matches stored directory path
|
||||||
using namespace boost::filesystem;
|
using namespace std::filesystem;
|
||||||
auto const stored{path(sPath)};
|
auto const stored{std::filesystem::path(sPath)};
|
||||||
if (stored.parent_path() == dbPath)
|
if (stored.parent_path() == dbPath)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@@ -410,9 +414,9 @@ SHAMapStoreImp::dbPaths()
|
|||||||
bool writableDbExists = false;
|
bool writableDbExists = false;
|
||||||
bool archiveDbExists = false;
|
bool archiveDbExists = false;
|
||||||
|
|
||||||
std::vector<boost::filesystem::path> pathsToDelete;
|
std::vector<std::filesystem::path> pathsToDelete;
|
||||||
for (boost::filesystem::directory_iterator it(dbPath);
|
for (std::filesystem::directory_iterator it(dbPath);
|
||||||
it != boost::filesystem::directory_iterator();
|
it != std::filesystem::directory_iterator();
|
||||||
++it)
|
++it)
|
||||||
{
|
{
|
||||||
if (state.writableDb.compare(it->path().string()) == 0)
|
if (state.writableDb.compare(it->path().string()) == 0)
|
||||||
@@ -433,7 +437,7 @@ SHAMapStoreImp::dbPaths()
|
|||||||
(!archiveDbExists && !state.archiveDb.empty()) || (writableDbExists != archiveDbExists) ||
|
(!archiveDbExists && !state.archiveDb.empty()) || (writableDbExists != archiveDbExists) ||
|
||||||
state.writableDb.empty() != state.archiveDb.empty())
|
state.writableDb.empty() != state.archiveDb.empty())
|
||||||
{
|
{
|
||||||
boost::filesystem::path stateDbPathName = app_.config().legacy("database_path");
|
std::filesystem::path stateDbPathName = app_.config().legacy("database_path");
|
||||||
stateDbPathName /= dbName_;
|
stateDbPathName /= dbName_;
|
||||||
stateDbPathName += "*";
|
stateDbPathName += "*";
|
||||||
|
|
||||||
@@ -455,15 +459,15 @@ SHAMapStoreImp::dbPaths()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// The necessary directories exist. Now, remove any others.
|
// The necessary directories exist. Now, remove any others.
|
||||||
for (boost::filesystem::path const& p : pathsToDelete)
|
for (std::filesystem::path const& p : pathsToDelete)
|
||||||
boost::filesystem::remove_all(p);
|
std::filesystem::remove_all(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<NodeStore::Backend>
|
std::unique_ptr<NodeStore::Backend>
|
||||||
SHAMapStoreImp::makeBackendRotating(std::string path)
|
SHAMapStoreImp::makeBackendRotating(std::string path)
|
||||||
{
|
{
|
||||||
Section section{app_.config().section(ConfigSection::nodeDatabase())};
|
Section section{app_.config().section(ConfigSection::nodeDatabase())};
|
||||||
boost::filesystem::path newPath;
|
std::filesystem::path newPath;
|
||||||
|
|
||||||
if (!path.empty())
|
if (!path.empty())
|
||||||
{
|
{
|
||||||
@@ -471,10 +475,24 @@ SHAMapStoreImp::makeBackendRotating(std::string path)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
boost::filesystem::path p = get(section, "path");
|
std::filesystem::path const p = get(section, "path");
|
||||||
p /= dbPrefix_;
|
std::random_device rd;
|
||||||
p += ".%%%%";
|
constexpr std::size_t maxAttempts = 100;
|
||||||
newPath = boost::filesystem::unique_path(p);
|
for (std::size_t attempt = 0; attempt < maxAttempts; ++attempt)
|
||||||
|
{
|
||||||
|
std::ostringstream oss;
|
||||||
|
oss << std::hex << std::setfill('0') << std::setw(8) << rd() << std::setw(8) << rd();
|
||||||
|
auto const candidate =
|
||||||
|
std::filesystem::path((p / dbPrefix_).string() + "." + oss.str());
|
||||||
|
std::error_code existsEc;
|
||||||
|
if (!std::filesystem::exists(candidate, existsEc) && !existsEc)
|
||||||
|
{
|
||||||
|
newPath = candidate;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (newPath.empty())
|
||||||
|
Throw<std::runtime_error>("Unable to generate a unique rotating backend path");
|
||||||
}
|
}
|
||||||
section.set("path", newPath.string());
|
section.set("path", newPath.string());
|
||||||
|
|
||||||
|
|||||||
@@ -12,6 +12,7 @@
|
|||||||
|
|
||||||
#include <boost/thread/shared_mutex.hpp>
|
#include <boost/thread/shared_mutex.hpp>
|
||||||
|
|
||||||
|
#include <filesystem>
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
#include <shared_mutex>
|
#include <shared_mutex>
|
||||||
|
|
||||||
@@ -204,7 +205,7 @@ class ValidatorList
|
|||||||
ManifestCache& validatorManifests_;
|
ManifestCache& validatorManifests_;
|
||||||
ManifestCache& publisherManifests_;
|
ManifestCache& publisherManifests_;
|
||||||
TimeKeeper& timeKeeper_;
|
TimeKeeper& timeKeeper_;
|
||||||
boost::filesystem::path const dataPath_;
|
std::filesystem::path const dataPath_;
|
||||||
beast::Journal const j_;
|
beast::Journal const j_;
|
||||||
std::shared_mutex mutable mutex_;
|
std::shared_mutex mutable mutex_;
|
||||||
using lock_guard = std::lock_guard<decltype(mutex_)>;
|
using lock_guard = std::lock_guard<decltype(mutex_)>;
|
||||||
@@ -803,7 +804,7 @@ private:
|
|||||||
|
|
||||||
/** Get the filename used for caching UNLs
|
/** Get the filename used for caching UNLs
|
||||||
*/
|
*/
|
||||||
boost::filesystem::path
|
std::filesystem::path
|
||||||
getCacheFileName(lock_guard const&, PublicKey const& pubKey) const;
|
getCacheFileName(lock_guard const&, PublicKey const& pubKey) const;
|
||||||
|
|
||||||
/** Build a Json representation of the collection, suitable for
|
/** Build a Json representation of the collection, suitable for
|
||||||
|
|||||||
@@ -29,12 +29,8 @@
|
|||||||
#include <xrpl/server/Manifest.h>
|
#include <xrpl/server/Manifest.h>
|
||||||
#include <xrpl/server/NetworkOPs.h>
|
#include <xrpl/server/NetworkOPs.h>
|
||||||
|
|
||||||
#include <boost/filesystem/operations.hpp>
|
|
||||||
#include <boost/regex/v5/regex.hpp>
|
#include <boost/regex/v5/regex.hpp>
|
||||||
#include <boost/regex/v5/regex_match.hpp>
|
#include <boost/regex/v5/regex_match.hpp>
|
||||||
#include <boost/system/detail/errc.hpp>
|
|
||||||
#include <boost/system/detail/error_code.hpp>
|
|
||||||
#include <boost/system/errc.hpp>
|
|
||||||
|
|
||||||
#include <xrpl.pb.h>
|
#include <xrpl.pb.h>
|
||||||
|
|
||||||
@@ -43,6 +39,7 @@
|
|||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
#include <filesystem>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <iterator>
|
#include <iterator>
|
||||||
#include <limits>
|
#include <limits>
|
||||||
@@ -54,6 +51,7 @@
|
|||||||
#include <shared_mutex>
|
#include <shared_mutex>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <string_view>
|
#include <string_view>
|
||||||
|
#include <system_error>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
@@ -288,7 +286,7 @@ ValidatorList::load(
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
boost::filesystem::path
|
std::filesystem::path
|
||||||
ValidatorList::getCacheFileName(ValidatorList::lock_guard const&, PublicKey const& pubKey) const
|
ValidatorList::getCacheFileName(ValidatorList::lock_guard const&, PublicKey const& pubKey) const
|
||||||
{
|
{
|
||||||
return dataPath_ / (filePrefix_ + strHex(pubKey));
|
return dataPath_ / (filePrefix_ + strHex(pubKey));
|
||||||
@@ -372,9 +370,9 @@ ValidatorList::cacheValidatorFile(ValidatorList::lock_guard const& lock, PublicK
|
|||||||
if (dataPath_.empty())
|
if (dataPath_.empty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
boost::filesystem::path const filename = getCacheFileName(lock, pubKey);
|
std::filesystem::path const filename = getCacheFileName(lock, pubKey);
|
||||||
|
|
||||||
boost::system::error_code ec;
|
std::error_code ec;
|
||||||
|
|
||||||
Json::Value value = buildFileData(strHex(pubKey), publisherLists_.at(pubKey), j_);
|
Json::Value value = buildFileData(strHex(pubKey), publisherLists_.at(pubKey), j_);
|
||||||
// xrpld should be the only process writing to this file, so
|
// xrpld should be the only process writing to this file, so
|
||||||
@@ -1283,8 +1281,7 @@ std::vector<std::string>
|
|||||||
ValidatorList::loadLists()
|
ValidatorList::loadLists()
|
||||||
{
|
{
|
||||||
using namespace std::string_literals;
|
using namespace std::string_literals;
|
||||||
using namespace boost::filesystem;
|
using namespace std::filesystem;
|
||||||
using namespace boost::system::errc;
|
|
||||||
|
|
||||||
std::lock_guard const lock{mutex_};
|
std::lock_guard const lock{mutex_};
|
||||||
|
|
||||||
@@ -1292,12 +1289,12 @@ ValidatorList::loadLists()
|
|||||||
sites.reserve(publisherLists_.size());
|
sites.reserve(publisherLists_.size());
|
||||||
for (auto const& [pubKey, publisherCollection] : publisherLists_)
|
for (auto const& [pubKey, publisherCollection] : publisherLists_)
|
||||||
{
|
{
|
||||||
boost::system::error_code ec;
|
std::error_code ec;
|
||||||
|
|
||||||
if (publisherCollection.status == PublisherStatus::available)
|
if (publisherCollection.status == PublisherStatus::available)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
boost::filesystem::path const filename = getCacheFileName(lock, pubKey);
|
std::filesystem::path const filename = getCacheFileName(lock, pubKey);
|
||||||
|
|
||||||
auto const fullPath{canonical(filename, ec)};
|
auto const fullPath{canonical(filename, ec)};
|
||||||
if (ec)
|
if (ec)
|
||||||
@@ -1308,7 +1305,7 @@ ValidatorList::loadLists()
|
|||||||
{
|
{
|
||||||
// Treat an empty file as a missing file, because
|
// Treat an empty file as a missing file, because
|
||||||
// nobody else is going to write it.
|
// nobody else is going to write it.
|
||||||
ec = make_error_code(no_such_file_or_directory);
|
ec = make_error_code(std::errc::no_such_file_or_directory);
|
||||||
}
|
}
|
||||||
if (ec)
|
if (ec)
|
||||||
continue;
|
continue;
|
||||||
|
|||||||
@@ -37,10 +37,8 @@
|
|||||||
#include <xrpl/rdb/RelationalDatabase.h>
|
#include <xrpl/rdb/RelationalDatabase.h>
|
||||||
#include <xrpl/rdb/SociDB.h>
|
#include <xrpl/rdb/SociDB.h>
|
||||||
|
|
||||||
#include <boost/filesystem/operations.hpp>
|
|
||||||
#include <boost/format/free_funcs.hpp>
|
#include <boost/format/free_funcs.hpp>
|
||||||
#include <boost/optional/optional.hpp>
|
#include <boost/optional/optional.hpp>
|
||||||
#include <boost/system/detail/error_code.hpp>
|
|
||||||
|
|
||||||
#include <soci/blob.h>
|
#include <soci/blob.h>
|
||||||
#include <soci/into.h>
|
#include <soci/into.h>
|
||||||
@@ -53,6 +51,7 @@
|
|||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <exception>
|
#include <exception>
|
||||||
|
#include <filesystem>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <limits>
|
#include <limits>
|
||||||
#include <map>
|
#include <map>
|
||||||
@@ -61,6 +60,7 @@
|
|||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <system_error>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
#include <variant>
|
#include <variant>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
@@ -1290,8 +1290,8 @@ getTransaction(
|
|||||||
bool
|
bool
|
||||||
dbHasSpace(soci::session& session, Config const& config, beast::Journal j)
|
dbHasSpace(soci::session& session, Config const& config, beast::Journal j)
|
||||||
{
|
{
|
||||||
boost::filesystem::space_info const space =
|
std::filesystem::space_info const space =
|
||||||
boost::filesystem::space(config.legacy("database_path"));
|
std::filesystem::space(config.legacy("database_path"));
|
||||||
|
|
||||||
if (space.available < megabytes(512))
|
if (space.available < megabytes(512))
|
||||||
{
|
{
|
||||||
@@ -1302,9 +1302,9 @@ dbHasSpace(soci::session& session, Config const& config, beast::Journal j)
|
|||||||
if (config.useTxTables())
|
if (config.useTxTables())
|
||||||
{
|
{
|
||||||
DatabaseCon::Setup const dbSetup = setup_DatabaseCon(config);
|
DatabaseCon::Setup const dbSetup = setup_DatabaseCon(config);
|
||||||
boost::filesystem::path const dbPath = dbSetup.dataDir / TxDBName;
|
std::filesystem::path const dbPath = dbSetup.dataDir / TxDBName;
|
||||||
boost::system::error_code ec;
|
std::error_code ec;
|
||||||
std::optional<std::uint64_t> dbSize = boost::filesystem::file_size(dbPath, ec);
|
std::optional<std::uint64_t> dbSize = std::filesystem::file_size(dbPath, ec);
|
||||||
if (ec)
|
if (ec)
|
||||||
{
|
{
|
||||||
JLOG(j.error()) << "Error checking transaction db file size: " << ec.message();
|
JLOG(j.error()) << "Error checking transaction db file size: " << ec.message();
|
||||||
|
|||||||
@@ -9,9 +9,8 @@
|
|||||||
#include <xrpl/protocol/SystemParameters.h> // VFALCO Breaks levelization
|
#include <xrpl/protocol/SystemParameters.h> // VFALCO Breaks levelization
|
||||||
#include <xrpl/rdb/DatabaseCon.h>
|
#include <xrpl/rdb/DatabaseCon.h>
|
||||||
|
|
||||||
#include <boost/filesystem.hpp> // VFALCO FIX: This include should not be here
|
|
||||||
|
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
#include <filesystem>
|
||||||
#include <optional>
|
#include <optional>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <unordered_set>
|
#include <unordered_set>
|
||||||
@@ -82,17 +81,17 @@ public:
|
|||||||
static char const* const validatorsFileName;
|
static char const* const validatorsFileName;
|
||||||
|
|
||||||
/** Returns the full path and filename of the debug log file. */
|
/** Returns the full path and filename of the debug log file. */
|
||||||
[[nodiscard]] boost::filesystem::path
|
[[nodiscard]] std::filesystem::path
|
||||||
getDebugLogFile() const;
|
getDebugLogFile() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
boost::filesystem::path CONFIG_FILE;
|
std::filesystem::path CONFIG_FILE;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
boost::filesystem::path CONFIG_DIR;
|
std::filesystem::path CONFIG_DIR;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
boost::filesystem::path DEBUG_LOGFILE;
|
std::filesystem::path DEBUG_LOGFILE;
|
||||||
|
|
||||||
void
|
void
|
||||||
load();
|
load();
|
||||||
|
|||||||
@@ -22,21 +22,19 @@
|
|||||||
#include <boost/algorithm/string/replace.hpp>
|
#include <boost/algorithm/string/replace.hpp>
|
||||||
#include <boost/algorithm/string/split.hpp>
|
#include <boost/algorithm/string/split.hpp>
|
||||||
#include <boost/algorithm/string/trim.hpp>
|
#include <boost/algorithm/string/trim.hpp>
|
||||||
#include <boost/filesystem/operations.hpp>
|
|
||||||
#include <boost/filesystem/path.hpp>
|
|
||||||
#include <boost/format/free_funcs.hpp>
|
#include <boost/format/free_funcs.hpp>
|
||||||
#include <boost/multiprecision/detail/endian.hpp>
|
#include <boost/multiprecision/detail/endian.hpp>
|
||||||
#include <boost/predef.h>
|
#include <boost/predef.h>
|
||||||
#include <boost/regex.hpp> // IWYU pragma: keep
|
#include <boost/regex.hpp> // IWYU pragma: keep
|
||||||
#include <boost/regex/v5/regex.hpp>
|
#include <boost/regex/v5/regex.hpp>
|
||||||
#include <boost/regex/v5/regex_match.hpp>
|
#include <boost/regex/v5/regex_match.hpp>
|
||||||
#include <boost/system/detail/error_code.hpp>
|
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <array>
|
#include <array>
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
|
#include <filesystem>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <iterator>
|
#include <iterator>
|
||||||
#include <limits>
|
#include <limits>
|
||||||
@@ -46,6 +44,7 @@
|
|||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <system_error>
|
||||||
#include <thread>
|
#include <thread>
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
@@ -313,13 +312,13 @@ Config::setup(std::string const& strConf, bool bQuiet, bool bSilent, bool bStand
|
|||||||
// directory, use the current working directory as the
|
// directory, use the current working directory as the
|
||||||
// config directory and that with "db" as the data
|
// config directory and that with "db" as the data
|
||||||
// directory.
|
// directory.
|
||||||
boost::filesystem::path dataDir;
|
std::filesystem::path dataDir;
|
||||||
|
|
||||||
if (!strConf.empty())
|
if (!strConf.empty())
|
||||||
{
|
{
|
||||||
// --conf=<path> : everything is relative that file.
|
// --conf=<path> : everything is relative that file.
|
||||||
CONFIG_FILE = strConf;
|
CONFIG_FILE = strConf;
|
||||||
CONFIG_DIR = boost::filesystem::absolute(CONFIG_FILE);
|
CONFIG_DIR = std::filesystem::absolute(CONFIG_FILE);
|
||||||
CONFIG_DIR.remove_filename();
|
CONFIG_DIR.remove_filename();
|
||||||
dataDir = CONFIG_DIR / databaseDirName;
|
dataDir = CONFIG_DIR / databaseDirName;
|
||||||
}
|
}
|
||||||
@@ -330,13 +329,13 @@ Config::setup(std::string const& strConf, bool bQuiet, bool bSilent, bool bStand
|
|||||||
// Check if either of the config files exist in the current working
|
// Check if either of the config files exist in the current working
|
||||||
// directory, in which case the databases will be stored in a
|
// directory, in which case the databases will be stored in a
|
||||||
// subdirectory.
|
// subdirectory.
|
||||||
CONFIG_DIR = boost::filesystem::current_path();
|
CONFIG_DIR = std::filesystem::current_path();
|
||||||
dataDir = CONFIG_DIR / databaseDirName;
|
dataDir = CONFIG_DIR / databaseDirName;
|
||||||
CONFIG_FILE = CONFIG_DIR / configFileName;
|
CONFIG_FILE = CONFIG_DIR / configFileName;
|
||||||
if (boost::filesystem::exists(CONFIG_FILE))
|
if (std::filesystem::exists(CONFIG_FILE))
|
||||||
break;
|
break;
|
||||||
CONFIG_FILE = CONFIG_DIR / configLegacyName;
|
CONFIG_FILE = CONFIG_DIR / configLegacyName;
|
||||||
if (boost::filesystem::exists(CONFIG_FILE))
|
if (std::filesystem::exists(CONFIG_FILE))
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// Check if the home directory is set, and optionally the XDG config
|
// Check if the home directory is set, and optionally the XDG config
|
||||||
@@ -363,10 +362,10 @@ Config::setup(std::string const& strConf, bool bQuiet, bool bSilent, bool bStand
|
|||||||
dataDir = strXdgDataHome + "/" + systemName();
|
dataDir = strXdgDataHome + "/" + systemName();
|
||||||
CONFIG_DIR = strXdgConfigHome + "/" + systemName();
|
CONFIG_DIR = strXdgConfigHome + "/" + systemName();
|
||||||
CONFIG_FILE = CONFIG_DIR / configFileName;
|
CONFIG_FILE = CONFIG_DIR / configFileName;
|
||||||
if (boost::filesystem::exists(CONFIG_FILE))
|
if (std::filesystem::exists(CONFIG_FILE))
|
||||||
break;
|
break;
|
||||||
CONFIG_FILE = CONFIG_DIR / configLegacyName;
|
CONFIG_FILE = CONFIG_DIR / configLegacyName;
|
||||||
if (boost::filesystem::exists(CONFIG_FILE))
|
if (std::filesystem::exists(CONFIG_FILE))
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -374,7 +373,7 @@ Config::setup(std::string const& strConf, bool bQuiet, bool bSilent, bool bStand
|
|||||||
dataDir = "/var/opt/" + systemName();
|
dataDir = "/var/opt/" + systemName();
|
||||||
CONFIG_DIR = "/etc/opt/" + systemName();
|
CONFIG_DIR = "/etc/opt/" + systemName();
|
||||||
CONFIG_FILE = CONFIG_DIR / configFileName;
|
CONFIG_FILE = CONFIG_DIR / configFileName;
|
||||||
if (boost::filesystem::exists(CONFIG_FILE))
|
if (std::filesystem::exists(CONFIG_FILE))
|
||||||
break;
|
break;
|
||||||
CONFIG_FILE = CONFIG_DIR / configLegacyName;
|
CONFIG_FILE = CONFIG_DIR / configLegacyName;
|
||||||
} while (false);
|
} while (false);
|
||||||
@@ -387,7 +386,7 @@ Config::setup(std::string const& strConf, bool bQuiet, bool bSilent, bool bStand
|
|||||||
std::string const dbPath(legacy("database_path"));
|
std::string const dbPath(legacy("database_path"));
|
||||||
if (!dbPath.empty())
|
if (!dbPath.empty())
|
||||||
{
|
{
|
||||||
dataDir = boost::filesystem::path(dbPath);
|
dataDir = std::filesystem::path(dbPath);
|
||||||
}
|
}
|
||||||
else if (RUN_STANDALONE)
|
else if (RUN_STANDALONE)
|
||||||
{
|
{
|
||||||
@@ -397,13 +396,13 @@ Config::setup(std::string const& strConf, bool bQuiet, bool bSilent, bool bStand
|
|||||||
|
|
||||||
if (!dataDir.empty())
|
if (!dataDir.empty())
|
||||||
{
|
{
|
||||||
boost::system::error_code ec;
|
std::error_code ec;
|
||||||
boost::filesystem::create_directories(dataDir, ec);
|
std::filesystem::create_directories(dataDir, ec);
|
||||||
|
|
||||||
if (ec)
|
if (ec)
|
||||||
Throw<std::runtime_error>(boost::str(boost::format("Can not create %s") % dataDir));
|
Throw<std::runtime_error>(boost::str(boost::format("Can not create %s") % dataDir));
|
||||||
|
|
||||||
legacy("database_path", boost::filesystem::absolute(dataDir).string());
|
legacy("database_path", std::filesystem::absolute(dataDir).string());
|
||||||
}
|
}
|
||||||
|
|
||||||
HTTPClient::initializeSSLContext(
|
HTTPClient::initializeSSLContext(
|
||||||
@@ -456,7 +455,7 @@ Config::load()
|
|||||||
if (!QUIET)
|
if (!QUIET)
|
||||||
std::cerr << "Loading: " << CONFIG_FILE << "\n";
|
std::cerr << "Loading: " << CONFIG_FILE << "\n";
|
||||||
|
|
||||||
boost::system::error_code ec;
|
std::error_code ec;
|
||||||
auto const fileContents = getFileContents(ec, CONFIG_FILE);
|
auto const fileContents = getFileContents(ec, CONFIG_FILE);
|
||||||
|
|
||||||
if (ec)
|
if (ec)
|
||||||
@@ -509,8 +508,8 @@ Config::loadFromString(std::string const& fileContents)
|
|||||||
std::string dbPath;
|
std::string dbPath;
|
||||||
if (getSingleSection(secConfig, "database_path", dbPath, j_))
|
if (getSingleSection(secConfig, "database_path", dbPath, j_))
|
||||||
{
|
{
|
||||||
boost::filesystem::path const p(dbPath);
|
std::filesystem::path const p(dbPath);
|
||||||
legacy("database_path", boost::filesystem::absolute(p).string());
|
legacy("database_path", std::filesystem::absolute(p).string());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -953,7 +952,7 @@ Config::loadFromString(std::string const& fileContents)
|
|||||||
// If no path was specified, then look for validators.txt
|
// If no path was specified, then look for validators.txt
|
||||||
// in the same directory as the config file, but don't complain
|
// in the same directory as the config file, but don't complain
|
||||||
// if we can't find it.
|
// if we can't find it.
|
||||||
boost::filesystem::path validatorsFile;
|
std::filesystem::path validatorsFile;
|
||||||
|
|
||||||
if (getSingleSection(secConfig, SECTION_VALIDATORS_FILE, strTemp, j_))
|
if (getSingleSection(secConfig, SECTION_VALIDATORS_FILE, strTemp, j_))
|
||||||
{
|
{
|
||||||
@@ -968,7 +967,7 @@ Config::loadFromString(std::string const& fileContents)
|
|||||||
if (!validatorsFile.is_absolute() && !CONFIG_DIR.empty())
|
if (!validatorsFile.is_absolute() && !CONFIG_DIR.empty())
|
||||||
validatorsFile = CONFIG_DIR / validatorsFile;
|
validatorsFile = CONFIG_DIR / validatorsFile;
|
||||||
|
|
||||||
if (!boost::filesystem::exists(validatorsFile))
|
if (!std::filesystem::exists(validatorsFile))
|
||||||
{
|
{
|
||||||
Throw<std::runtime_error>(
|
Throw<std::runtime_error>(
|
||||||
"The file specified in [" SECTION_VALIDATORS_FILE
|
"The file specified in [" SECTION_VALIDATORS_FILE
|
||||||
@@ -977,8 +976,8 @@ Config::loadFromString(std::string const& fileContents)
|
|||||||
validatorsFile.string());
|
validatorsFile.string());
|
||||||
}
|
}
|
||||||
else if (
|
else if (
|
||||||
!boost::filesystem::is_regular_file(validatorsFile) &&
|
!std::filesystem::is_regular_file(validatorsFile) &&
|
||||||
!boost::filesystem::is_symlink(validatorsFile))
|
!std::filesystem::is_symlink(validatorsFile))
|
||||||
{
|
{
|
||||||
Throw<std::runtime_error>(
|
Throw<std::runtime_error>(
|
||||||
"Invalid file specified in [" SECTION_VALIDATORS_FILE "]: " +
|
"Invalid file specified in [" SECTION_VALIDATORS_FILE "]: " +
|
||||||
@@ -991,24 +990,24 @@ Config::loadFromString(std::string const& fileContents)
|
|||||||
|
|
||||||
if (!validatorsFile.empty())
|
if (!validatorsFile.empty())
|
||||||
{
|
{
|
||||||
if (!boost::filesystem::exists(validatorsFile))
|
if (!std::filesystem::exists(validatorsFile))
|
||||||
{
|
{
|
||||||
validatorsFile.clear();
|
validatorsFile.clear();
|
||||||
}
|
}
|
||||||
else if (
|
else if (
|
||||||
!boost::filesystem::is_regular_file(validatorsFile) &&
|
!std::filesystem::is_regular_file(validatorsFile) &&
|
||||||
!boost::filesystem::is_symlink(validatorsFile))
|
!std::filesystem::is_symlink(validatorsFile))
|
||||||
{
|
{
|
||||||
validatorsFile.clear();
|
validatorsFile.clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!validatorsFile.empty() && boost::filesystem::exists(validatorsFile) &&
|
if (!validatorsFile.empty() && std::filesystem::exists(validatorsFile) &&
|
||||||
(boost::filesystem::is_regular_file(validatorsFile) ||
|
(std::filesystem::is_regular_file(validatorsFile) ||
|
||||||
boost::filesystem::is_symlink(validatorsFile)))
|
std::filesystem::is_symlink(validatorsFile)))
|
||||||
{
|
{
|
||||||
boost::system::error_code ec;
|
std::error_code ec;
|
||||||
auto const data = getFileContents(ec, validatorsFile);
|
auto const data = getFileContents(ec, validatorsFile);
|
||||||
if (ec)
|
if (ec)
|
||||||
{
|
{
|
||||||
@@ -1134,7 +1133,7 @@ Config::loadFromString(std::string const& fileContents)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
boost::filesystem::path
|
std::filesystem::path
|
||||||
Config::getDebugLogFile() const
|
Config::getDebugLogFile() const
|
||||||
{
|
{
|
||||||
auto log_file = DEBUG_LOGFILE;
|
auto log_file = DEBUG_LOGFILE;
|
||||||
@@ -1143,17 +1142,17 @@ Config::getDebugLogFile() const
|
|||||||
{
|
{
|
||||||
// Unless an absolute path for the log file is specified, the
|
// Unless an absolute path for the log file is specified, the
|
||||||
// path is relative to the config file directory.
|
// path is relative to the config file directory.
|
||||||
log_file = boost::filesystem::absolute(log_file, CONFIG_DIR);
|
log_file = CONFIG_DIR / log_file;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!log_file.empty())
|
if (!log_file.empty())
|
||||||
{
|
{
|
||||||
auto log_dir = log_file.parent_path();
|
auto log_dir = log_file.parent_path();
|
||||||
|
|
||||||
if (!boost::filesystem::is_directory(log_dir))
|
if (!std::filesystem::is_directory(log_dir))
|
||||||
{
|
{
|
||||||
boost::system::error_code ec;
|
std::error_code ec;
|
||||||
boost::filesystem::create_directories(log_dir, ec);
|
std::filesystem::create_directories(log_dir, ec);
|
||||||
|
|
||||||
// If we fail, we warn but continue so that the calling code can
|
// If we fail, we warn but continue so that the calling code can
|
||||||
// decide how to handle this situation.
|
// decide how to handle this situation.
|
||||||
|
|||||||
@@ -13,11 +13,9 @@
|
|||||||
#include <xrpl/json/json_writer.h>
|
#include <xrpl/json/json_writer.h>
|
||||||
#include <xrpl/protocol/jss.h>
|
#include <xrpl/protocol/jss.h>
|
||||||
|
|
||||||
#include <boost/filesystem/operations.hpp>
|
|
||||||
#include <boost/system/detail/error_code.hpp>
|
|
||||||
|
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
#include <filesystem>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <ios>
|
#include <ios>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
@@ -25,6 +23,7 @@
|
|||||||
#include <ostream>
|
#include <ostream>
|
||||||
#include <set>
|
#include <set>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <system_error>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
@@ -216,10 +215,10 @@ PerfLogImp::openLog()
|
|||||||
logFile_.close();
|
logFile_.close();
|
||||||
|
|
||||||
auto logDir = setup_.perfLog.parent_path();
|
auto logDir = setup_.perfLog.parent_path();
|
||||||
if (!boost::filesystem::is_directory(logDir))
|
if (!std::filesystem::is_directory(logDir))
|
||||||
{
|
{
|
||||||
boost::system::error_code ec;
|
std::error_code ec;
|
||||||
boost::filesystem::create_directories(logDir, ec);
|
std::filesystem::create_directories(logDir, ec);
|
||||||
if (ec)
|
if (ec)
|
||||||
{
|
{
|
||||||
JLOG(j_.fatal()) << "Unable to create performance log "
|
JLOG(j_.fatal()) << "Unable to create performance log "
|
||||||
@@ -474,17 +473,17 @@ PerfLogImp::stop()
|
|||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
PerfLog::Setup
|
PerfLog::Setup
|
||||||
setup_PerfLog(Section const& section, boost::filesystem::path const& configDir)
|
setup_PerfLog(Section const& section, std::filesystem::path const& configDir)
|
||||||
{
|
{
|
||||||
PerfLog::Setup setup;
|
PerfLog::Setup setup;
|
||||||
std::string perfLog;
|
std::string perfLog;
|
||||||
set(perfLog, "perf_log", section);
|
set(perfLog, "perf_log", section);
|
||||||
if (!perfLog.empty())
|
if (!perfLog.empty())
|
||||||
{
|
{
|
||||||
setup.perfLog = boost::filesystem::path(perfLog);
|
setup.perfLog = std::filesystem::path(perfLog);
|
||||||
if (setup.perfLog.is_relative())
|
if (setup.perfLog.is_relative())
|
||||||
{
|
{
|
||||||
setup.perfLog = boost::filesystem::absolute(setup.perfLog, configDir);
|
setup.perfLog = configDir / setup.perfLog;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user