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

Added better CURRENT file handling #9

Merged
merged 1 commit into from
Oct 5, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 10 additions & 11 deletions db/version_set.cc
Original file line number Diff line number Diff line change
Expand Up @@ -916,20 +916,19 @@ Status VersionSet::Recover(bool *save_manifest) {
if (!s.ok()) {
return s;
}
const size_t size = current.size();
const size_t maxSize = current.size();
size_t size = 0;
// find the first non-printable character (eg null, carriage return or newline)
for (size = 0; size < maxSize; size++){
if (current[size] < 32)
break;
}
current.resize(size);
if (size == 0) {
if (maxSize != 0)
return Status::NotSupported("CURRENT file did not contain a valid manifest name. Marketplace worlds are not supported.");
return Status::Corruption("CURRENT file is empty");
}

int resizeSize = 0;
while (current[size - resizeSize - 1] == '\n' || current[size - resizeSize - 1] == '\r') {
resizeSize += 1;
if (size <= resizeSize) {
return Status::Corruption("CURRENT file is empty");
}
}

current.resize(size - resizeSize);

std::string dscname = dbname_ + "/" + current;
SequentialFile* file;
Expand Down