1
0
mirror of synced 2024-11-25 00:00:27 +01:00

fix: File provider sometimes not saving path to project file

This commit is contained in:
WerWolv 2023-01-19 11:09:24 +01:00
parent def40c908e
commit c5d2739a39
2 changed files with 10 additions and 5 deletions

View File

@ -51,10 +51,12 @@ namespace hex {
bool result = true;
for (const auto &handler : ProjectFile::getHandlers()) {
try {
if (!handler.load(handler.basePath, tar))
if (!handler.load(handler.basePath, tar)) {
log::warn("Project file handler for {} failed to load {}", filePath.string(), handler.basePath.string());
result = false;
}
} catch (std::exception &e) {
log::info("{}", e.what());
log::warn("Project file handler for {} failed to load {}: {}", filePath.string(), handler.basePath.string(), e.what());
result = false;
}

View File

@ -297,10 +297,13 @@ namespace hex::plugin::builtin {
}
nlohmann::json FileProvider::storeSettings(nlohmann::json settings) const {
std::string path;
if (auto projectPath = ProjectFile::getPath(); !projectPath.empty())
settings["path"] = hex::toUTF8String(std::fs::relative(this->m_path, projectPath.parent_path()));
else
settings["path"] = hex::toUTF8String(this->m_path);
path = hex::toUTF8String(std::fs::proximate(this->m_path, projectPath.parent_path()));
if (path.empty())
path = hex::toUTF8String(this->m_path);
settings["path"] = path;
return Provider::storeSettings(settings);
}