fix bug where use_mmap was ignored

This commit is contained in:
Jan Petykiewicz 2024-07-28 20:21:02 -07:00
parent b10803efe9
commit 7e1f617274

View File

@ -597,7 +597,7 @@ def load_libraryfile(
path = pathlib.Path(filename) path = pathlib.Path(filename)
stream: IO[bytes] stream: IO[bytes]
if is_gzipped(path): if is_gzipped(path):
if mmap: if use_mmap:
logger.info('Asked to mmap a gzipped file, reading into memory instead...') logger.info('Asked to mmap a gzipped file, reading into memory instead...')
gz_stream = gzip.open(path, mode='rb') gz_stream = gzip.open(path, mode='rb')
stream = io.BytesIO(gz_stream.read()) # type: ignore stream = io.BytesIO(gz_stream.read()) # type: ignore
@ -605,7 +605,7 @@ def load_libraryfile(
gz_stream = gzip.open(path, mode='rb') gz_stream = gzip.open(path, mode='rb')
stream = io.BufferedReader(gz_stream) # type: ignore stream = io.BufferedReader(gz_stream) # type: ignore
else: # noqa: PLR5501 else: # noqa: PLR5501
if mmap: if use_mmap:
base_stream = open(path, mode='rb', buffering=0) base_stream = open(path, mode='rb', buffering=0)
stream = mmap.mmap(base_stream.fileno(), 0, access=mmap.ACCESS_READ) # type: ignore stream = mmap.mmap(base_stream.fileno(), 0, access=mmap.ACCESS_READ) # type: ignore
else: else: