diff --git a/doc/releases/0.101.1.rst b/doc/releases/0.101.1.rst index c24372868c..eeb54566a6 100644 --- a/doc/releases/0.101.1.rst +++ b/doc/releases/0.101.1.rst @@ -15,6 +15,7 @@ Main changes: core: +* Update the method of creating an empty file with right size when saving binary files (#3408) * Refactor pandas save load and convert dtypes (#3412) * Check run info completed only if it exists (back-compatibility) (#3407) * Fix argument spelling in check for binary compatibility (#3409) @@ -72,6 +73,7 @@ curation: widgets: +* Fix metrics widgets for convert_dtypes (#3417) * Fix plot motion for multi-segment (#3414) * Sortingview: only round float properties (#3406) * Fix widgets tests and add test on unit_table_properties (#3354) diff --git a/src/spikeinterface/core/recording_tools.py b/src/spikeinterface/core/recording_tools.py index 5137eda545..77d427bc88 100644 --- a/src/spikeinterface/core/recording_tools.py +++ b/src/spikeinterface/core/recording_tools.py @@ -131,9 +131,12 @@ def write_binary_recording( data_size_bytes = dtype_size_bytes * num_frames * num_channels file_size_bytes = data_size_bytes + byte_offset - file = open(file_path, "wb+") - file.truncate(file_size_bytes) - file.close() + # Create an empty file with file_size_bytes + with open(file_path, "wb+") as file: + # The previous implementation `file.truncate(file_size_bytes)` was slow on Windows (#3408) + file.seek(file_size_bytes - 1) + file.write(b"\0") + assert Path(file_path).is_file() # use executor (loop or workers)