Skip to content

Commit

Permalink
fix: avoid possible name clashes when storing logs in DC output file
Browse files Browse the repository at this point in the history
  • Loading branch information
paulmueller committed Apr 17, 2024
1 parent 2328397 commit 893d6d7
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
0.6.3
- fix: cleanup temporary directories on startup (#29)
- fix: avoid possible name clashes when storing logs in DC output file
- enh: warn user when source and target directory are identical (#28)
0.6.2
- setup: bump dclab from 0.55.7 to 0.57.0
Expand Down
15 changes: 12 additions & 3 deletions mpl_data_cast/mod_recipes/rcp_rtdc.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,18 @@ def convert_dataset(self, path_list, temp_path, **kwargs):
if len(path_list) > 1:
with dclab.RTDCWriter(temp_path, compression_kwargs=cmp_kw) as hw:
for pp in path_list[1:]:
lines = pp.read_text().split("\n")
lines = [ll.rstrip() for ll in lines]
hw.store_log(pp.name, lines)
while True:
# avoid name clashes
ii = 0
log_name = pp.name + f"-{ii}" if ii else pp.name
if log_name in hw.h5file.get("logs", {}):
ii += 1
continue
# write the log file
lines = pp.read_text().split("\n")
lines = [ll.rstrip() for ll in lines]
hw.store_log(log_name, lines)
break

def get_raw_data_iterator(self):
"""Get list of .rtdc files including associated files"""
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ classifiers = [
license = {text = "GPL v3"}
dependencies = [
"click>=8",
"dclab>=0.57.0",
"dclab>=0.58.2",
"h5py>=3.8.0",
"hdf5plugin", # compression
"numpy>=1.21", # CVE-2021-33430
Expand Down

0 comments on commit 893d6d7

Please sign in to comment.