Skip to content

Commit 97bdff1

Browse files
author
Andrei Neagu
committed
install path is now fixed to avoid using old system versions
1 parent 9ca1090 commit 97bdff1

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

packages/service-library/src/servicelib/archiving_utils/_interface_7zip.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@
3434
# NOTE: the size of `chunk_to_emit` should in theory contain everything that above regexes capture
3535
_DEFAULT_CHUNK_SIZE: Final[NonNegativeInt] = 20
3636

37+
_7ZIP_PATH: Final[Path] = Path("/usr/bin/7z")
38+
3739

3840
class ArchiveInfoParser:
3941
def __init__(self) -> None:
@@ -124,6 +126,7 @@ async def _output_reader(
124126

125127
lookbehind_buffer = "" # store the last chunk
126128

129+
# TODO: rewrite the scrolling window to be a bit longer so that we could capture bigger numbers
127130
while True:
128131
read_chunk = await stream.read(chunk_size)
129132
if not read_chunk:
@@ -204,7 +207,7 @@ async def archive_dir(
204207
"-mta=off", # Don't store file access time
205208
]
206209
)
207-
command = f"7z {options} {destination} {dir_to_compress}/*"
210+
command = f"{_7ZIP_PATH} {options} {destination} {dir_to_compress}/*"
208211

209212
folder_size_bytes = sum(
210213
file.stat().st_size for file in iter_files_to_compress(dir_to_compress)
@@ -252,7 +255,7 @@ async def unarchive_dir(
252255
# get archive information
253256
archive_info_parser = ArchiveInfoParser()
254257
await _run_cli_command(
255-
f"7z l {archive_to_extract}",
258+
f"{_7ZIP_PATH} l {archive_to_extract}",
256259
output_handlers=[archive_info_parser.parse_chunk],
257260
)
258261
total_bytes, file_count = archive_info_parser.get_parsed_values()
@@ -286,7 +289,7 @@ async def progress_handler(byte_progress: NonNegativeInt) -> None:
286289
]
287290
)
288291
await _run_cli_command(
289-
f"7z {options} {archive_to_extract} -o{destination_folder}",
292+
f"{_7ZIP_PATH} {options} {archive_to_extract} -o{destination_folder}",
290293
output_handlers=[ProgressParser(progress_handler).parse_chunk],
291294
)
292295

0 commit comments

Comments
 (0)