Fix Windows MAX_PATH failures for percent-encoded wiki filenames.

Cap encoded slug length and use \\?\ long-path writes (0.3.6).

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
mihailkudravcev
2026-07-24 10:55:31 +03:00
parent d91c454099
commit dc8be1bd1a
6 changed files with 106 additions and 49 deletions
+6 -5
View File
@@ -7,6 +7,8 @@ import shutil
import subprocess
from pathlib import Path
from export1c_help.fscompat import copy_file, ensure_dir, remove_file
# Always owned by export_1c_help (not user articles).
_MANAGED_FIXED = frozenset({"Home.md", "History.md", "_Sidebar.md", "manifest.json"})
_IMAGE_SUFFIXES = frozenset({".png", ".jpg", ".jpeg", ".gif", ".bmp", ".webp"})
@@ -46,7 +48,7 @@ def prepare_wiki_clone(
else:
if work_dir.exists():
shutil.rmtree(work_dir)
work_dir.parent.mkdir(parents=True, exist_ok=True)
ensure_dir(work_dir.parent)
_run(
[
"git",
@@ -115,13 +117,13 @@ def push_wiki(
continue
suf = path.suffix.lower()
if suf in {".md", ".json"} or suf in _IMAGE_SUFFIXES:
path.unlink()
remove_file(path)
else:
# Drop help pages that disappeared from the configuration export.
for name in sorted(prev_managed - new_files):
path = work_dir / name
if path.is_file():
path.unlink()
remove_file(path)
for src in content_dir.iterdir():
if src.name == ".git":
@@ -140,8 +142,7 @@ def push_wiki(
shutil.rmtree(dst)
shutil.copytree(src, dst)
else:
dst.parent.mkdir(parents=True, exist_ok=True)
shutil.copy2(src, dst)
copy_file(src, dst)
_run(["git", "add", "-A"], cwd=work_dir)
status = _run(["git", "status", "--porcelain"], cwd=work_dir)