table: snapshot_exists: Get directory from storage options

Similarly to snapshot_on_all_shards, the way snapshot directory is
evaluated is changed to rely on storage options. Two ... assumptions are
that when asking for non-local snapshot existance or for a snapshot of a
virtual table, it's correct to return false instead of throwing.

Signed-off-by: Pavel Emelyanov <xemul@scylladb.com>
This commit is contained in:
Pavel Emelyanov
2024-09-17 18:25:13 +03:00
parent 24589cf00c
commit a734fd5c9c

View File

@@ -2663,7 +2663,12 @@ future<> table::finalize_snapshot(database& db, sstring jsondir, std::vector<sna
}
future<bool> table::snapshot_exists(sstring tag) {
sstring jsondir = _config.datadir + "/snapshots/" + tag;
auto* so = std::get_if<storage_options::local>(&_storage_opts->value);
if (so == nullptr || so->dir.empty()) {
co_return false; // Technically it doesn't as snapshots only work for local storage
}
sstring jsondir = (so->dir / sstables::snapshots_dir / tag).native();
bool exists = false;
try {
auto sd = co_await io_check(file_stat, jsondir, follow_symlink::no);