HDF5: Improvements in data file and master file safety.
Build Packages / build:rpm (rocky9_sls9) (push) Failing after 4m5s
Build Packages / build:rpm (rocky8_nocuda) (push) Successful in 9m47s
Build Packages / build:rpm (ubuntu2204_nocuda) (push) Successful in 10m30s
Build Packages / build:rpm (rocky9_nocuda) (push) Successful in 11m30s
Build Packages / build:rpm (ubuntu2404_nocuda) (push) Successful in 8m56s
Build Packages / build:rpm (rocky8_sls9) (push) Successful in 10m15s
Build Packages / build:rpm (rocky8) (push) Successful in 8m47s
Build Packages / XDS test (durin plugin) (push) Failing after 7m12s
Build Packages / build:rpm (rocky9) (push) Successful in 14m7s
Build Packages / build:rpm (ubuntu2404) (push) Successful in 12m10s
Build Packages / build:rpm (ubuntu2204) (push) Successful in 12m38s
Build Packages / Generate python client (push) Successful in 25s
Build Packages / Create release (push) Has been skipped
Build Packages / XDS test (JFJoch plugin) (push) Failing after 6m55s
Build Packages / DIALS test (push) Successful in 11m47s
Build Packages / Build documentation (push) Successful in 57s
Build Packages / XDS test (neggia plugin) (push) Successful in 12m44s
Build Packages / Unit tests (push) Successful in 1h22m52s

This commit is contained in:
2026-05-04 11:23:18 +02:00
parent b7136cc92d
commit 3a81c88394
2 changed files with 49 additions and 10 deletions
+22 -8
View File
@@ -78,11 +78,22 @@ std::optional<HDF5DataFileStatistics> HDF5DataFile::Close() {
data_set->Close();
data_set.reset();
}
data_file->Close();
data_file.reset();
if (manage_file && (!std::filesystem::exists(filename.c_str()) || overwrite))
std::rename(tmp_filename.c_str(), filename.c_str());
if (manage_file ) {
data_file->Close();
data_file.reset();
if (std::filesystem::exists(filename) && !overwrite)
throw JFJochException(JFJochExceptionCategory::FileWriteError, "File already exists");
std::error_code ec;
std::filesystem::rename(tmp_filename, filename, ec);
if (ec)
throw JFJochException(JFJochExceptionCategory::FileWriteError,
"Cannot rename temporary HDF5 file " + tmp_filename +
" to " + filename + ": " + ec.message());
} else {
data_file.reset();
}
closed = true;
@@ -92,16 +103,19 @@ std::optional<HDF5DataFileStatistics> HDF5DataFile::Close() {
ret.filename = filename;
ret.file_number = file_number + 1;
return ret;
}
HDF5DataFile::~HDF5DataFile() {
if (data_file) {
try {
data_set->Close();
data_file->Close();
std::filesystem::remove(tmp_filename);
data_set.reset();
data_set_image_number.reset();
data_file.reset();
if (manage_file) {
std::error_code ec;
std::filesystem::remove(tmp_filename, ec);
}
} catch (const std::exception &e) {
std::cerr << "HDF5DataFile::~HDF5DataFile: " << e.what() << std::endl;
} catch (...) {