Skip to content

Commit

Permalink
For local files: read file completely instead of leaving a dangling open
Browse files Browse the repository at this point in the history
  • Loading branch information
bjhardcastle committed Mar 20, 2024
1 parent 1555e7d commit 2c3e78a
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/npc_sync/sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,12 +268,14 @@ def load(self, path) -> h5py.File:
self.dfile = h5py.File(path, "r")
except OSError:
path = npc_io.from_pathlike(path)
ffspec_storage_options = {}
if path.protocol not in ("", "file"):
ffspec_storage_options["cache_type"] = "first"
self.dfile = h5py.File(
path.open(mode="rb", **ffspec_storage_options), "r"
)
if path.protocol in ("", "file"):
self.dfile = h5py.File(
path.as_posix(), "r"
)
else:
self.dfile = h5py.File(
path.open(mode="rb", cache_type="first"), "r"
)
return self.dfile

@property
Expand Down

0 comments on commit 2c3e78a

Please sign in to comment.