Preserve Windows target write authorization for atomic editor saves

未关闭
#2,441 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 3 天内回复

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
38/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
活跃
领域
desktop, devtools

调研方向

Start with src/integrations/editor/DiffViewProvider.ts and inspect saveDirectly, safeWriteText, and the relevant Windows filesystem tests. First clarify the maintainer’s intended authorization check, then reproduce the DACL case where direct writes are denied but replacement and fs.access(..., W_OK) succeed. Done means the save rejects without changing the target, and error and missing-target paths pass on the rebased head.

由索引模型根据 Issue 内容生成。

描述

Problem

At PR #1395 head 925f8b7bf9f90e69cd83e12a4dfcf08483d7213f, DiffViewProvider.saveDirectly in src/integrations/editor/DiffViewProvider.ts checks the existing target with fs.access(..., W_OK) before publishing with safeWriteText. On Windows, that check does not establish authorization under the target's DACL. A target can deny file writes while its parent permits replacement, so rename-based publication can replace a file that the previous fs.writeFile path would reject.

Required work

  • Obtain the maintainer decision on the authorization check that saveDirectly should own.
  • Implement the selected check without truncating the existing target before publication. Preserve the intended atomic publication behavior.
  • Add a Windows real-filesystem regression test for saveDirectly. Establish that direct file writes are denied, replacement is permitted, and fs.access(..., W_OK) succeeds. Verify that the save rejects and the target content remains unchanged.
  • Retest the relevant error and missing-target paths, and verify the final implementation on the rebased head.

The Windows DACL integration case in PR #2385 at 078cd7eb84c7377bdf8741f3564bfd14e5d69e82 exercises safeWriteText and post-publication DACL preservation or restore reporting. It does not verify the saveDirectly authorization decision.

Reported sizing

The author reported a candidate at 43e7d85ba63712abde83b8396aaa8d45220fab53 costing 11 counted executable lines and 3 selector ranges on a separate plain-fs.writeFile branch. The author reported 487 of 500 counted lines with that candidate alone at the measured chain top, and 505 of 500 with both review changes. These are author measurements, not a verified estimate for a fix to the rename-based path. Recalculate the cost for the chosen implementation.

Requested by @easonLiangWorldedtech.

PR: https://github.com/Zoo-Code-Org/Zoo-Code/pull/1395
Review finding: https://github.com/Zoo-Code-Org/Zoo-Code/pull/1395#discussion_r4510971756

主要语言
TypeScript
星标
2k
派生
301
平均合并
3 天 14 小时
30 天内合并 PR
103

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

Zoo-Code-Org/Zoo-Code 的其他 Issue

查看 Zoo-Code-Org/Zoo-Code 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。