Skip to content

Commit 1de423e

Browse files
committed
wallet: introduce method to return all db created files
1 parent d04f6a9 commit 1de423e

File tree

4 files changed

+13
-0
lines changed

4 files changed

+13
-0
lines changed

src/wallet/db.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,9 @@ class WalletDatabase
155155
/** Return path to main database file for logs and error messages. */
156156
virtual std::string Filename() = 0;
157157

158+
/** Return paths to all database created files */
159+
virtual std::vector<fs::path> Files() = 0;
160+
158161
virtual std::string Format() = 0;
159162

160163
/** Make a DatabaseBatch connected to this database */

src/wallet/migrate.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ class BerkeleyRODatabase : public WalletDatabase
5050

5151
/** Return path to main database file for logs and error messages. */
5252
std::string Filename() override { return fs::PathToString(m_filepath); }
53+
std::vector<fs::path> Files() override { return {m_filepath}; }
5354

5455
std::string Format() override { return "bdb_ro"; }
5556

src/wallet/sqlite.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,14 @@ class SQLiteDatabase : public WalletDatabase
147147
bool Backup(const std::string& dest) const override;
148148

149149
std::string Filename() override { return m_file_path; }
150+
/** Return paths to all database created files */
151+
std::vector<fs::path> Files() override
152+
{
153+
std::vector<fs::path> files;
154+
files.emplace_back(m_dir_path / fs::PathFromString(m_file_path));
155+
files.emplace_back(m_dir_path / fs::PathFromString(m_file_path + "-journal"));
156+
return files;
157+
}
150158
std::string Format() override { return "sqlite"; }
151159

152160
/** Make a SQLiteBatch connected to this database */

src/wallet/test/util.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ class MockableDatabase : public WalletDatabase
109109
void Close() override {}
110110

111111
std::string Filename() override { return "mockable"; }
112+
std::vector<fs::path> Files() override { return {}; }
112113
std::string Format() override { return "mock"; }
113114
std::unique_ptr<DatabaseBatch> MakeBatch() override { return std::make_unique<MockableBatch>(m_records, m_pass); }
114115
};

0 commit comments

Comments
 (0)