paulsengroup / hictk

Blazing fast toolkit to work with .hic and .cool files
MIT License
23 stars 1 forks source link

Fix temporary file name collisions in hictk convert *cool -> hic #274

Closed robomics closed 4 weeks ago

robomics commented 1 month ago

This PR fixes the bug reported in https://github.com/paulsengroup/hictk/issues/271.

This bug is a regression introduced by https://github.com/paulsengroup/hictk/pull/210.

In brief, when performing *cool -> hic conversion, a randomly-named, self-deleting temporary directory was created under the default temporary directory (e.g. /tmp) or a user provided temporary folder. However, due to a silly mistake, the parent of this folder was passed to one of the functions creating temporary files. When converting multiple files sharing one or more resolution in parallel using the default temporary folder, this results in unintended file truncation (which could lead to all kinds of errors).

Other commands creating .hic files (e.g. hictk load and hictk zoomify) are not affected.

codecov[bot] commented 1 month ago

Codecov Report

Attention: Patch coverage is 80.00000% with 1 line in your changes missing coverage. Please review.

Project coverage is 79.01%. Comparing base (0dafc0d) to head (a59f894). Report is 26 commits behind head on main.

Files with missing lines Patch % Lines
src/hictk/convert/cool_to_hic.cpp 50.00% 1 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #274 +/- ## ========================================== - Coverage 79.02% 79.01% -0.02% ========================================== Files 171 171 Lines 16324 16327 +3 Branches 2250 2250 ========================================== Hits 12900 12900 - Misses 2455 2457 +2 - Partials 969 970 +1 ``` | [Flag](https://app.codecov.io/gh/paulsengroup/hictk/pull/274/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=paulsengroup) | Coverage Δ | | |---|---|---| | [tests | integration](https://app.codecov.io/gh/paulsengroup/hictk/pull/274/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=paulsengroup) | `69.38% <80.00%> (-0.04%)` | :arrow_down: | | [tests | unittests](https://app.codecov.io/gh/paulsengroup/hictk/pull/274/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=paulsengroup) | `76.43% <100.00%> (-0.01%)` | :arrow_down: | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=paulsengroup#carryforward-flags-in-the-pull-request-comment) to find out more.

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.