fix: 皮肤包替换忽略 __MACOSX 及隐藏文件

macOS 压缩产生的皮肤 zip 顶层含 __MACOSX 目录,导致解压后判定为
多目录、退回使用解压根目录作 THEME,从而把 __MACOSX 和真实皮肤目录
一并复制进 Images.xcassets。解压统计顶层条目时过滤 __MACOSX 与隐藏
文件,并在 _apply_theme 复制时兜底跳过,使 THEME 正确下钻到真实皮肤
目录。旧皮肤包不含这些条目,行为不变,完全兼容。

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
shenlei
2026-07-29 15:32:45 +09:00
co-authored by Claude Opus 4.8
parent 605c09c88a
commit 9d766a0b58
2 changed files with 9 additions and 1 deletions
+6 -1
View File
@@ -675,7 +675,12 @@ async def generate_config(task_id: str, task, build_dir: Path) -> dict:
skin_extract_dir.mkdir(exist_ok=True) skin_extract_dir.mkdir(exist_ok=True)
with zipfile.ZipFile(skin_zip, "r") as zf: with zipfile.ZipFile(skin_zip, "r") as zf:
zf.extractall(skin_extract_dir) zf.extractall(skin_extract_dir)
entries = list(skin_extract_dir.iterdir()) # 过滤掉 macOS 压缩产生的 __MACOSX 及隐藏文件,避免把它们
# 当成皮肤资源目录一起复制进 Images.xcassets。
entries = [
e for e in skin_extract_dir.iterdir()
if e.name != "__MACOSX" and not e.name.startswith(".")
]
if len(entries) == 1 and entries[0].is_dir(): if len(entries) == 1 and entries[0].is_dir():
config_data["THEME"] = str(entries[0]) config_data["THEME"] = str(entries[0])
else: else:
+3
View File
@@ -68,6 +68,9 @@ def _apply_theme(build_dir: Path, theme_dir: str, messages: list[str]):
for item in source.iterdir(): for item in source.iterdir():
if not item.is_dir(): if not item.is_dir():
continue continue
# 跳过 macOS 压缩包内的 __MACOSX 及隐藏目录,仅复制真实皮肤资源
if item.name == "__MACOSX" or item.name.startswith("."):
continue
destination = target_assets / item.name destination = target_assets / item.name
if destination.exists(): if destination.exists():
shutil.rmtree(destination) shutil.rmtree(destination)