Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BackupContainerFilesystem no longer unnecessarily depends on abspath().. #2693

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions documentation/sphinx/source/release-notes.rst
Expand Up @@ -11,6 +11,7 @@ Fixes
* Storage servers could fail to advance their version correctly in response to empty commits. `(PR #2617) <https://github.com/apple/foundationdb/pull/2617>`_.
* Status could not label more than 5 processes as proxies. `(PR #2653) <https://github.com/apple/foundationdb/pull/2653>`_.
* The ``TR_FLAG_DISABLE_MACHINE_TEAM_REMOVER``, ``TR_FLAG_REMOVE_MT_WITH_MOST_TEAMS``, ``TR_FLAG_DISABLE_SERVER_TEAM_REMOVER``, and ``BUGGIFY_ALL_COORDINATION`` knobs could not be set at runtime. `(PR #2661) <https://github.com/apple/foundationdb/pull/2661>`_.
* Backup container filename parsing was unnecessarily consulting the local filesystem which will error when permission is denied. `(PR #2693) <https://github.com/apple/foundationdb/pull/2693>`_.

6.2.15
======
Expand Down
21 changes: 18 additions & 3 deletions fdbclient/BackupContainer.actor.cpp
Expand Up @@ -348,8 +348,23 @@ class BackupContainerFileSystem : public IBackupContainer {
return writeFile(snapshotFolderString(snapshotBeginVersion) + format("/%d/", snapshotFileCount / (BUGGIFY ? 1 : 5000)) + fileName);
}

// Find what should be the filename of a path by finding whatever is after the last forward or backward slash, or failing to find those, the whole string.
static std::string fileNameOnly(std::string path) {
// Find the last forward slash position, defaulting to 0 if not found
int pos = path.find_last_of('/');
if(pos == std::string::npos) {
pos = 0;
}
// Find the last backward slash position after pos, and update pos if found
int b = path.find_last_of('\\', pos);
if(b != std::string::npos) {
pos = b;
}
satherton marked this conversation as resolved.
Show resolved Hide resolved
return path.substr(pos + 1);
}

static bool pathToRangeFile(RangeFile &out, std::string path, int64_t size) {
std::string name = basename(path);
std::string name = fileNameOnly(path);
RangeFile f;
f.fileName = path;
f.fileSize = size;
Expand All @@ -362,7 +377,7 @@ class BackupContainerFileSystem : public IBackupContainer {
}

static bool pathToLogFile(LogFile &out, std::string path, int64_t size) {
std::string name = basename(path);
std::string name = fileNameOnly(path);
LogFile f;
f.fileName = path;
f.fileSize = size;
Expand All @@ -375,7 +390,7 @@ class BackupContainerFileSystem : public IBackupContainer {
}

static bool pathToKeyspaceSnapshotFile(KeyspaceSnapshotFile &out, std::string path) {
std::string name = basename(path);
std::string name = fileNameOnly(path);
KeyspaceSnapshotFile f;
f.fileName = path;
int len;
Expand Down