Skip to content

Commit

Permalink
Remove extra slash for manifest file path (#333)
Browse files Browse the repository at this point in the history
Remove extra slash manifest file path
  • Loading branch information
weili-openai authored Aug 20, 2024
1 parent d1370d9 commit bfd97aa
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 11 deletions.
3 changes: 3 additions & 0 deletions cloud/cloud_file_system_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2307,6 +2307,9 @@ IOStatus CloudFileSystemImpl::FindLiveFilesFromLocalManifest(
}

std::string CloudFileSystemImpl::CloudManifestFile(const std::string& dbname) {
if (dbname.empty()) {
return MakeCloudManifestFile(cloud_fs_options.cookie_on_open);
}
return MakeCloudManifestFile(dbname, cloud_fs_options.cookie_on_open);
}

Expand Down
2 changes: 1 addition & 1 deletion cloud/db_cloud_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ Status DBCloudImpl::DoCheckpointToCloud(

// Create a temp MANIFEST file first as this captures all the files we need
auto current_epoch = cfs->GetCloudManifest()->GetCurrentEpoch();
auto manifest_fname = ManifestFileWithEpoch("", current_epoch);
auto manifest_fname = ManifestFileWithEpoch(current_epoch);
auto tmp_manifest_fname = manifest_fname + ".tmp";
st = CopyFile(local_fs.get(), GetName() + "/" + manifest_fname,
Temperature::kUnknown, GetName() + "/" + tmp_manifest_fname,
Expand Down
25 changes: 15 additions & 10 deletions cloud/filename.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@

#pragma once

#include <rocksdb/slice.h>

#include <algorithm>
#include <functional>
#include <string>
#include <cstring>

#include <rocksdb/slice.h>

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

inline std::string MakeCloudManifestFile(const std::string& dbname, const std::string& cookie) {
return cookie.empty() ? (dbname + "/CLOUDMANIFEST")
: (dbname + "/CLOUDMANIFEST-" + cookie);
inline std::string MakeCloudManifestFile(const std::string& cookie) {
return cookie.empty() ? "CLOUDMANIFEST" : "CLOUDMANIFEST-" + cookie;
}
inline std::string MakeCloudManifestFile(const std::string& dbname,
const std::string& cookie) {
assert(!dbname.empty());
return dbname + "/" + MakeCloudManifestFile(cookie);
}

inline std::string ManifestFileWithEpoch(const std::string& epoch) {
return epoch.empty() ? "MANIFEST" : "MANIFEST-" + epoch;
}
inline std::string ManifestFileWithEpoch(const std::string& dbname,
const std::string& epoch) {
return epoch.empty() ? (dbname + "/MANIFEST")
: (dbname + "/MANIFEST-" + epoch);
assert(!dbname.empty());
return dbname + "/" + ManifestFileWithEpoch(epoch);
}


inline std::string RemoveEpoch(const std::string& path) {
auto lastDash = path.rfind('-');
if (lastDash == std::string::npos) {
Expand All @@ -114,7 +119,7 @@ inline std::string GetCookie(const std::string& cloud_manifest_file_path) {
return "";
}

return cloud_manifest_fname.substr(firstDash+1);
return cloud_manifest_fname.substr(firstDash + 1);
}

// pathaname seperator
Expand Down

0 comments on commit bfd97aa

Please sign in to comment.