From d3847caab4ec9e369be5d0d9d48a77b7b918eb98 Mon Sep 17 00:00:00 2001 From: Gary Talent Date: Thu, 28 Dec 2023 00:24:18 -0600 Subject: [PATCH] [olympic/studio] Make Project::writeObj only write descriptor if it does not already exist or if debug build --- .../studio/modlib/include/studio/project.hpp | 22 ++++++++++++------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/src/olympic/studio/modlib/include/studio/project.hpp b/src/olympic/studio/modlib/include/studio/project.hpp index 8efc7bb9..47a57bea 100644 --- a/src/olympic/studio/modlib/include/studio/project.hpp +++ b/src/olympic/studio/modlib/include/studio/project.hpp @@ -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()); + 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().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);