Skip to content

Commit 528fea0

Browse files
committed
Fix for empty extraction directories.
1 parent b1f762f commit 528fea0

2 files changed

Lines changed: 10 additions & 5 deletions

File tree

cachebin/cachebin.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ def extract_archive(archive_path: Path | str, extract_path: Path | str) -> Path:
9494
if top_item.is_directory:
9595
extracted_parent_directory = extract_path / top_item.filename
9696

97-
if not extracted_parent_directory.exists():
97+
if not extracted_parent_directory.exists() or not any(extracted_parent_directory.iterdir()):
9898
print(f"Extracting {archive_path} to {extract_path}...")
9999
archive.extractall(path=extract_path)
100100
return extracted_parent_directory
@@ -166,7 +166,8 @@ def __init__(
166166
get_archive_extension: Callable[[str], str], # returns archive extension based on system
167167
get_platform_string: Callable[[str, str], str] = lambda system,
168168
architecture: f"{system}-{architecture}", # returns platform string used in url_pattern
169-
get_extracted_bin_path: Callable[[str], str] = lambda _: "bin", # returns extracted bin path based on system
169+
get_extracted_bin_path: Callable[[str, str], str] = lambda system,
170+
architecture: "bin", # returns extracted bin path
170171
cache_directory: Path | str | None = None,
171172
):
172173
self.package_name = package_name
@@ -175,7 +176,7 @@ def __init__(
175176
self._architecture = machine().lower()
176177
self._platform_string = get_platform_string(self._system, self._architecture)
177178
self._extension = get_archive_extension(self._system)
178-
self._extracted_bin_path = get_extracted_bin_path(self._system)
179+
self._extracted_bin_path = get_extracted_bin_path(self._system, self._architecture)
179180

180181
self._cache_directory: Path
181182
if cache_directory is None:

cachebin/recipies.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,11 @@ def process_map(map: dict[str, str], key_description: str, key: str) -> str:
3131
get_archive_extension=lambda system: process_map(
3232
{"windows": "zip", "linux": "tar.gz", "darwin": "tgz"}, "system", system
3333
),
34-
get_extracted_bin_path=lambda system: f"bin/universal-{system}" if system == "darwin" else f"bin/{system}",
34+
get_extracted_bin_path=lambda system, architecture: f"bin/universal-{system}"
35+
if system == "darwin"
36+
else f"bin/{system}"
37+
if system == "windows"
38+
else f"bin/{architecture}-{system}",
3539
)
3640

3741
pandoc_crossref_manager = BinaryManager(
@@ -48,5 +52,5 @@ def process_map(map: dict[str, str], key_description: str, key: str) -> str:
4852
f"{system}-{architecture}",
4953
),
5054
get_archive_extension=lambda system: "7z" if system == "windows" else "tar.xz",
51-
get_extracted_bin_path=lambda _: "",
55+
get_extracted_bin_path=lambda system, architecture: "",
5256
)

0 commit comments

Comments
 (0)