[olympic/studio] Make Project::writeObj only write descriptor if it does not already exist or if debug build
All checks were successful
Build / build (push) Successful in 2m9s

This commit is contained in:
Gary Talent 2023-12-28 00:24:18 -06:00
parent ae066a914c
commit d3847caab4

View File

@ -125,14 +125,20 @@ ox::Error Project::writeObj(ox::CRStringView path, T const&obj, ox::ClawFormat f
}
// write out type store
auto const descPath = ox::sfmt("/{}/type_descriptors", m_projectDataDir);
oxReturnError(mkdir(descPath));
for (auto const&t : m_typeStore.typeList()) {
oxRequireM(typeOut, ox::writeClaw(*t, ox::ClawFormat::Organic));
// replace garbage last character with new line
*typeOut.back().value = '\n';
// write to FS
auto const typePath = ox::sfmt("/{}/{}", descPath, buildTypeId(*t));
oxReturnError(writeBuff(typePath, typeOut));
oxRequire(desc, m_typeStore.get<T>());
auto const descExists = m_fs.stat(ox::sfmt("{}/{}", descPath, buildTypeId(*desc))).error != 0;
if (!descExists || ox::defines::Debug) {
// write all descriptors because we don't know which types T depends on
oxReturnError(mkdir(descPath));
m_typeStore.get<T>().value;
for (auto const &t: m_typeStore.typeList()) {
oxRequireM(typeOut, ox::writeClaw(*t, ox::ClawFormat::Organic));
// replace garbage last character with new line
*typeOut.back().value = '\n';
// write to FS
auto const typePath = ox::sfmt("/{}/{}", descPath, buildTypeId(*t));
oxReturnError(writeBuff(typePath, typeOut));
}
}
oxReturnError(keel::setAsset(m_ctx, path, obj));
fileUpdated.emit(path);