fix(install): --dest 指到目录时拒绝安装,别把目录 rename 进隔离区

端到端实测(Z: 真共享盘,14:18)发现的:`--dest` 要的是文件路径,而第一版在两阶段提交的
"移走目标名上的东西" 一步不区分文件与目录 —— 传一个目录过去就把那个目录整块搬进了
`.transcode_trash`(0 字节、可回滚,但业主会看到目录凭空消失)。

现在:`live` 是目录 → 直接 `FAIL install refused: … exists and is a directory`,
目录与里面的文件一个都不动,源也留在原地(14:26 实测 keepme.txt 还在、源 4713 B 未动)。
同时把回执里的 `install.quarantine` 统一成文件名(原来 pre-publish 记文件名、post-install 记全路径)。
This commit is contained in:
hoelee committed 2026-11-01 14:27:55 +08:00
1 parent 46c9177386
commit 4b5cbe0ab6
1 file changed
+9 -1
+9 -1
View File
@@ -2047,6 +2047,13 @@ def process(src, args, dest=None, origin=None):
quarantined = [] # [(trash path, original path)]
targets = [live] if os.path.abspath(live) == os.path.abspath(src) else []
if not targets and os.path.exists(live):
# A DIRECTORY on the target name is not something to move aside: `--dest` takes a file
# path, so this is a mis-called run, and quietly renaming the owner's directory into the
# quarantine (measured 2026-11-01 14:18, an empty `out/`) hides the mistake instead of
# reporting it.
if os.path.isdir(live):
return ("FAIL install refused: %s exists and is a directory - `--dest` wants a file "
"path, nothing was replaced" % live), None
targets = [live] # an older output already sitting on the target name
for t in targets:
if origin_used and os.path.abspath(t) == os.path.abspath(src):
@@ -2118,7 +2125,8 @@ def process(src, args, dest=None, origin=None):
"install": {"how": how, "tail": tail_msg,
"cache_bypass": bool(bypassed and back_bypass),
"quarantine": [os.path.basename(p)
for p, _ in quarantined] + retired}}
for p, _ in quarantined]
+ [os.path.basename(p) for p in retired]}}
finally:
for p in (loc_src, loc_out):