Skip to content

Commit

Permalink
Clean up early if we threw an exception before all the models are dow…
Browse files Browse the repository at this point in the history
…nloaded
  • Loading branch information
malton-ont committed Dec 5, 2023
1 parent 85c46e4 commit 80703a3
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions dorado/cli/duplex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,21 +130,26 @@ DuplexModels load_models(const std::string& model_arg,
if (!mod_bases.empty()) {
std::transform(
mod_bases.begin(), mod_bases.end(), std::back_inserter(mods_model_paths),
[&model_arg](std::string m) {
[&model_arg](const std::string& m) {
return std::filesystem::path(models::get_modification_model(model_arg, m));
});
} else if (!mod_bases_models.empty()) {
const auto split = utils::split(mod_bases_models, ',');
std::transform(split.begin(), split.end(), std::back_inserter(mods_model_paths),
[&](std::string m) { return std::filesystem::path(m); });
[&](const std::string& m) { return std::filesystem::path(m); });
}

} else {
model_path = model_finder.fetch_simplex_model();
stereo_model_path = model_finder.fetch_stereo_model();
mods_model_paths = inferred_selection.has_mods_variant()
? model_finder.fetch_mods_models()
: std::vector<std::filesystem::path>{};
try {
model_path = model_finder.fetch_simplex_model();
stereo_model_path = model_finder.fetch_stereo_model();
mods_model_paths = inferred_selection.has_mods_variant()
? model_finder.fetch_mods_models()
: std::vector<std::filesystem::path>{};
} catch (const std::exception&) {
utils::clean_temporary_models(model_finder.downloaded_models());
throw;
}
}

const auto model_name = model_finder.get_simplex_model_name();
Expand Down

0 comments on commit 80703a3

Please sign in to comment.