Skip to content

Commit

Permalink
[hotfix] fix log file create failed caused by name too long
Browse files Browse the repository at this point in the history
  • Loading branch information
zoltar9264 committed May 20, 2023
1 parent de2ffe6 commit 8d3025c
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion file/filename.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,14 @@ static const std::string kRocksDBBlobFileExt = "blob";

// Given a path, flatten the path name by replacing all chars not in
// {[0-9,a-z,A-Z,-,_,.]} with _. And append '_LOG\0' at the end.
// If the given path append the '_LOG\0' longer then 255, only the last 255 characters will be kept.
// Return the number of chars stored in dest not including the trailing '\0'.
static size_t GetInfoLogPrefix(const std::string& path, char* dest, int len) {
const char suffix[] = "_LOG";
const size_t file_name_length_limit = 255;

size_t write_idx = 0;
size_t i = 0;
size_t i = std::max(static_cast<size_t>(0), path.length() - (file_name_length_limit - sizeof(suffix)));
size_t src_len = path.size();

while (i < src_len && write_idx < len - sizeof(suffix)) {
Expand Down

0 comments on commit 8d3025c

Please sign in to comment.