Skip to content

Commit 73a27b4

Browse files
committed
fix: add binary file extensions to prevent corruption during pack
1 parent 7035c31 commit 73a27b4

3 files changed

Lines changed: 60 additions & 4 deletions

File tree

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "uipath"
3-
version = "2.0.76"
3+
version = "2.0.77"
44
description = "Python SDK and CLI for UiPath Platform, enabling programmatic interaction with automation services, process management, and deployment tools."
55
readme = { file = "README.md", content-type = "text/markdown" }
66
requires-python = ">=3.10"
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,58 @@
11
BINDINGS_VERSION = "2.2"
2+
3+
# Binary file extension categories
4+
IMAGE_EXTENSIONS = {
5+
".png",
6+
".jpg",
7+
".jpeg",
8+
".gif",
9+
".bmp",
10+
".ico",
11+
".tiff",
12+
".webp",
13+
".svg",
14+
}
15+
16+
DOCUMENT_EXTENSIONS = {".pdf", ".docx", ".pptx", ".xlsx", ".xls"}
17+
18+
ARCHIVE_EXTENSIONS = {".zip", ".tar", ".gz", ".rar", ".7z", ".bz2", ".xz"}
19+
20+
MEDIA_EXTENSIONS = {
21+
".mp3",
22+
".wav",
23+
".flac",
24+
".aac",
25+
".mp4",
26+
".avi",
27+
".mov",
28+
".mkv",
29+
".wmv",
30+
}
31+
32+
FONT_EXTENSIONS = {".woff", ".woff2", ".ttf", ".otf", ".eot"}
33+
34+
EXECUTABLE_EXTENSIONS = {".exe", ".dll", ".so", ".dylib", ".bin"}
35+
36+
DATABASE_EXTENSIONS = {".db", ".sqlite", ".sqlite3"}
37+
38+
PYTHON_BINARY_EXTENSIONS = {".pickle", ".pkl"}
39+
40+
SPECIAL_EXTENSIONS = {""} # Extensionless binary files
41+
42+
# Pre-compute the union for optimal performance
43+
BINARY_EXTENSIONS = (
44+
IMAGE_EXTENSIONS
45+
| DOCUMENT_EXTENSIONS
46+
| ARCHIVE_EXTENSIONS
47+
| MEDIA_EXTENSIONS
48+
| FONT_EXTENSIONS
49+
| EXECUTABLE_EXTENSIONS
50+
| DATABASE_EXTENSIONS
51+
| PYTHON_BINARY_EXTENSIONS
52+
| SPECIAL_EXTENSIONS
53+
)
54+
55+
56+
def is_binary_file(file_extension: str) -> bool:
57+
"""Determine if a file should be treated as binary."""
58+
return file_extension.lower() in BINARY_EXTENSIONS

src/uipath/_cli/cli_pack.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
from ..telemetry import track
1919
from ._utils._console import ConsoleLogger
20+
from ._utils._constants import is_binary_file
2021

2122
console = ConsoleLogger()
2223

@@ -265,8 +266,6 @@ def pack_fn(
265266
# Define the allowlist of file extensions to include
266267
file_extensions_included = [".py", ".mermaid", ".json", ".yaml", ".yml"]
267268
files_included = []
268-
# Binary files that should be read in binary mode
269-
binary_extensions = [".exe", "", ".xlsx", ".xls"]
270269

271270
with open(config_path, "r") as f:
272271
config_data = json.load(f)
@@ -328,7 +327,7 @@ def pack_fn(
328327
if file_extension in file_extensions_included or file in files_included:
329328
file_path = os.path.join(root, file)
330329
rel_path = os.path.relpath(file_path, directory)
331-
if file_extension in binary_extensions:
330+
if is_binary_file(file_extension):
332331
# Read binary files in binary mode
333332
with open(file_path, "rb") as f:
334333
z.writestr(f"content/{rel_path}", f.read())

0 commit comments

Comments
 (0)