Skip to content

Commit

Permalink
Merge pull request #291 from paulsengroup/fix/remove-warning
Browse files Browse the repository at this point in the history
Make sure cooler::File::close() does not attempt to finalize files more than once
  • Loading branch information
robomics authored Oct 15, 2024
2 parents 12e6b4f + 76384dd commit 069ef5f
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/libhictk/cooler/include/hictk/cooler/impl/file_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,15 @@ inline File::operator bool() const noexcept { return !!_bins; }

inline void File::close() {
finalize();
*this = File{};
_datasets.clear();
_groups.clear();
_weights.clear();
_weights_scaled.clear();
_pixel_variant = std::int32_t{};
_bins.reset();
_index.reset();
_finalize = false;
_root_group = RootGroup{};
}

inline void File::finalize() {
Expand All @@ -327,10 +335,11 @@ inline void File::finalize() {

} catch (const std::exception &e) {
throw std::runtime_error(
fmt::format(FMT_STRING("The following error occurred while closing file {}: {}\n"
fmt::format(FMT_STRING("The following error occurred while finalizing file {}: {}\n"
"File is likely corrupted or incomplete"),
path(), e.what()));
}
_finalize = false;
}

inline HighFive::File File::open_file(std::string_view uri, unsigned int mode, bool validate) {
Expand Down

0 comments on commit 069ef5f

Please sign in to comment.