From 1de423e0a08bbc63eed36c8772e9ef8b48e80fb8 Mon Sep 17 00:00:00 2001 From: furszy Date: Wed, 11 Dec 2024 13:10:01 -0500 Subject: [PATCH] wallet: introduce method to return all db created files --- src/wallet/db.h | 3 +++ src/wallet/migrate.h | 1 + src/wallet/sqlite.h | 8 ++++++++ src/wallet/test/util.h | 1 + 4 files changed, 13 insertions(+) diff --git a/src/wallet/db.h b/src/wallet/db.h index 7870dcc4b22..96e1e5630e1 100644 --- a/src/wallet/db.h +++ b/src/wallet/db.h @@ -155,6 +155,9 @@ public: /** Return path to main database file for logs and error messages. */ virtual std::string Filename() = 0; + /** Return paths to all database created files */ + virtual std::vector Files() = 0; + virtual std::string Format() = 0; /** Make a DatabaseBatch connected to this database */ diff --git a/src/wallet/migrate.h b/src/wallet/migrate.h index 6f388809f0c..e72df288521 100644 --- a/src/wallet/migrate.h +++ b/src/wallet/migrate.h @@ -50,6 +50,7 @@ public: /** Return path to main database file for logs and error messages. */ std::string Filename() override { return fs::PathToString(m_filepath); } + std::vector Files() override { return {m_filepath}; } std::string Format() override { return "bdb_ro"; } diff --git a/src/wallet/sqlite.h b/src/wallet/sqlite.h index cb0c608dc60..895cfb12dd4 100644 --- a/src/wallet/sqlite.h +++ b/src/wallet/sqlite.h @@ -147,6 +147,14 @@ public: bool Backup(const std::string& dest) const override; std::string Filename() override { return m_file_path; } + /** Return paths to all database created files */ + std::vector Files() override + { + std::vector files; + files.emplace_back(m_dir_path / fs::PathFromString(m_file_path)); + files.emplace_back(m_dir_path / fs::PathFromString(m_file_path + "-journal")); + return files; + } std::string Format() override { return "sqlite"; } /** Make a SQLiteBatch connected to this database */ diff --git a/src/wallet/test/util.h b/src/wallet/test/util.h index 7a19806731b..4c84a1713f2 100644 --- a/src/wallet/test/util.h +++ b/src/wallet/test/util.h @@ -109,6 +109,7 @@ public: void Close() override {} std::string Filename() override { return "mockable"; } + std::vector Files() override { return {}; } std::string Format() override { return "mock"; } std::unique_ptr MakeBatch() override { return std::make_unique(m_records, m_pass); } };