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

--[Bugfix] - Storage of attribute source directory paths #2541

Merged
merged 2 commits into from
Feb 3, 2025
Merged
Changes from 1 commit
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
Prev Previous commit
--Properly account for config directory ending in os sep ('/')
  • Loading branch information
jturner65 committed Feb 3, 2025
commit 50a6ac5536cde71533ebc80810d329de66ce8908
19 changes: 6 additions & 13 deletions src/esp/metadata/managers/AbstractAttributesManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,7 @@ void AbstractAttributesManager<T, Access>::buildAttrSrcPathsFromJSONAndLoad(
const std::string& configDir,
const std::string& extType,
const io::JsonGenericValue& filePaths) {
std::size_t cfgLastDirLoc = configDir.find_last_of('/');
// configDir must end with an os sep (i.e. '/')
for (rapidjson::SizeType i = 0; i < filePaths.Size(); ++i) {
if (!filePaths[i].IsString()) {
ESP_WARNING(Mn::Debug::Flag::NoSpace)
Expand All @@ -501,23 +501,16 @@ void AbstractAttributesManager<T, Access>::buildAttrSrcPathsFromJSONAndLoad(
continue;
}
const char* fileString = filePaths[i].GetString();
// Only normalize paths for paths from config starting with ellipses.
// This is so that glob doesn't fail when the filepath from the config is
// trying to back-pedal across an OS link.
bool normalizePaths = (fileString[0] == '.') && (fileString[1] == '.') &&
(fileString[2] == '/');

// TODO Eventually we should normalize all metadata paths in the system
std::string dsFilePath =
normalizePaths ? CrPath::join(configDir.substr(0, cfgLastDirLoc),
std::string(fileString).substr(3))
: CrPath::join(configDir, fileString);
// The full filepath inferred by the given absolute config directory and the
// passed relative file paths
std::string dsFilePath = CrPath::join(configDir, fileString);

ESP_VERY_VERBOSE(Mn::Debug::Flag::NoSpace)
<< "<" << this->objectType_ << "> : Config dir : " << configDir
<< " : filePaths[" << i << "] : " << filePaths[i].GetString()
<< " : filePaths[" << i << "] : " << fileString
<< " | Constructed File Path : " << dsFilePath;

// Search in derived full filepath
std::vector<std::string> globPaths = io::globDirs(dsFilePath);
if (globPaths.size() > 0) {
for (const auto& globPath : globPaths) {
Expand Down
Loading