Skip to content

Commit bfd97aa

Browse files
authored
Remove extra slash for manifest file path (#333)
Remove extra slash manifest file path
1 parent d1370d9 commit bfd97aa

File tree

3 files changed

+19
-11
lines changed

3 files changed

+19
-11
lines changed

cloud/cloud_file_system_impl.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2307,6 +2307,9 @@ IOStatus CloudFileSystemImpl::FindLiveFilesFromLocalManifest(
23072307
}
23082308

23092309
std::string CloudFileSystemImpl::CloudManifestFile(const std::string& dbname) {
2310+
if (dbname.empty()) {
2311+
return MakeCloudManifestFile(cloud_fs_options.cookie_on_open);
2312+
}
23102313
return MakeCloudManifestFile(dbname, cloud_fs_options.cookie_on_open);
23112314
}
23122315

cloud/db_cloud_impl.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ Status DBCloudImpl::DoCheckpointToCloud(
336336

337337
// Create a temp MANIFEST file first as this captures all the files we need
338338
auto current_epoch = cfs->GetCloudManifest()->GetCurrentEpoch();
339-
auto manifest_fname = ManifestFileWithEpoch("", current_epoch);
339+
auto manifest_fname = ManifestFileWithEpoch(current_epoch);
340340
auto tmp_manifest_fname = manifest_fname + ".tmp";
341341
st = CopyFile(local_fs.get(), GetName() + "/" + manifest_fname,
342342
Temperature::kUnknown, GetName() + "/" + tmp_manifest_fname,

cloud/filename.h

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,11 @@
22

33
#pragma once
44

5+
#include <rocksdb/slice.h>
6+
57
#include <algorithm>
68
#include <functional>
79
#include <string>
8-
#include <cstring>
9-
10-
#include <rocksdb/slice.h>
1110

1211
//
1312
// These are inlined methods to deal with pathnames and filenames.
@@ -81,18 +80,24 @@ inline bool ends_with(std::string const& value, std::string const& ending) {
8180
return std::equal(ending.rbegin(), ending.rend(), value.rbegin());
8281
}
8382

84-
inline std::string MakeCloudManifestFile(const std::string& dbname, const std::string& cookie) {
85-
return cookie.empty() ? (dbname + "/CLOUDMANIFEST")
86-
: (dbname + "/CLOUDMANIFEST-" + cookie);
83+
inline std::string MakeCloudManifestFile(const std::string& cookie) {
84+
return cookie.empty() ? "CLOUDMANIFEST" : "CLOUDMANIFEST-" + cookie;
85+
}
86+
inline std::string MakeCloudManifestFile(const std::string& dbname,
87+
const std::string& cookie) {
88+
assert(!dbname.empty());
89+
return dbname + "/" + MakeCloudManifestFile(cookie);
8790
}
8891

92+
inline std::string ManifestFileWithEpoch(const std::string& epoch) {
93+
return epoch.empty() ? "MANIFEST" : "MANIFEST-" + epoch;
94+
}
8995
inline std::string ManifestFileWithEpoch(const std::string& dbname,
9096
const std::string& epoch) {
91-
return epoch.empty() ? (dbname + "/MANIFEST")
92-
: (dbname + "/MANIFEST-" + epoch);
97+
assert(!dbname.empty());
98+
return dbname + "/" + ManifestFileWithEpoch(epoch);
9399
}
94100

95-
96101
inline std::string RemoveEpoch(const std::string& path) {
97102
auto lastDash = path.rfind('-');
98103
if (lastDash == std::string::npos) {
@@ -114,7 +119,7 @@ inline std::string GetCookie(const std::string& cloud_manifest_file_path) {
114119
return "";
115120
}
116121

117-
return cloud_manifest_fname.substr(firstDash+1);
122+
return cloud_manifest_fname.substr(firstDash + 1);
118123
}
119124

120125
// pathaname seperator

0 commit comments

Comments
 (0)