Adding to .zip archive removes file system access rules
还没有人认领这个 Issue。
评估
调研方向
从 src/ICSharpCode.SharpZipLib/Zip/ZipFile.cs 开始,检查第 3132-3143 行附近的完成代码,以及第 4663-4713 行附近的临时和最终输出处理。使用提供的 AddEntryRevertingFilePermissions 测试重现该问题,然后添加回归覆盖,证明对存档设置的访问规则在 CommitUpdate() 后仍然保留。
由索引模型根据 Issue 内容生成。
描述
When adding to a .zip archive on disk, the update does not happen in place. Instead, a temporary .zip file with the updated contents is created in a temporary directory first, which replaces the original archive after a successful write. As a result, any file system access rules set on the .zip archive that is updated are lost.
Steps to reproduce
- Run the snippet below in a debugger
[Test]
[Category("Zip")]
[Category("CreatesTempFile")]
public void AddEntryRevertingFilePermissions()
{
const string TestValue = "0001000";
string tempFile = "c:/temp/";
Assert.IsNotNull(tempFile, "No permission to execute this test?");
tempFile = Path.Combine(tempFile, "SharpZipTest.Zip");
// create empty zip file
using (ZipFile f = ZipFile.Create(tempFile))
{
f.BeginUpdate();
f.CommitUpdate();
}
Console.WriteLine("break here and manually amend permissions for c:/temp/SharpZipTest.Zip by adding a rule");
using (ZipFile f = new ZipFile(tempFile))
{
var m = new StringMemoryDataSource(TestValue);
f.BeginUpdate();
f.Add(m, "a.dat");
f.CommitUpdate();
}
Console.WriteLine("permissions for c:/temp/SharpZipTest.Zip are reverted");
}
- Break in the middle and amend permissions to the file by adding an access rule.
- Run to completion and verify that the file permission has reverted.
Expected behavior
File permissions should be retained
Actual behavior
File permissions inherited from temporary directory (e.g. C:\Users\username\AppData\Local\Temp\) are set
Version of SharpZipLib
Obtained from (only keep the relevant lines)
- Compiled from source, commit: https://github.com/icsharpcode/SharpZipLib/commit/cd5310f5b7eed595110b76a2f7ae5ee013cc50f1
Further detail
The update is finalised: (directUpdate is false)
https://github.com/icsharpcode/SharpZipLib/blob/cd5310f5b7eed595110b76a2f7ae5ee013cc50f1/src/ICSharpCode.SharpZipLib/Zip/ZipFile.cs#L3132-L3143
The temporary output (pointing to a temporary directory ) is created at https://github.com/icsharpcode/SharpZipLib/blob/cd5310f5b7eed595110b76a2f7ae5ee013cc50f1/src/ICSharpCode.SharpZipLib/Zip/ZipFile.cs#L4663-L4669
The final output is created at
https://github.com/icsharpcode/SharpZipLib/blob/cd5310f5b7eed595110b76a2f7ae5ee013cc50f1/src/ICSharpCode.SharpZipLib/Zip/ZipFile.cs#L4676-L4713
- 主要语言
- C#
- 星标
- 3.9k
- 派生
- 1k
- PR 合并指标
- 30 天内没有已合并 PR
环境准备
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
icsharpcode/SharpZipLib 的其他 Issue
-
*no response* bug
难度 1/5 1 小时以内 新手友好度 78/100
icsharpcode/SharpZipLib#905 · 1 条评论 ·
-
bug bzip2
难度 4/5 3-5 天 新手友好度 45/100
icsharpcode/SharpZipLib#904 ·
-
enhancement zip
难度 2/5 1-2 天 新手友好度 55/100
icsharpcode/SharpZipLib#903 ·
-
*no response* bug
难度 4/5 3-5 天 新手友好度 32/100
icsharpcode/SharpZipLib#901 · 1 条评论 ·
-
*no response* bug
难度 4/5 3-5 天 新手友好度 35/100
icsharpcode/SharpZipLib#894 · 1 条评论 ·
查看 icsharpcode/SharpZipLib 的全部 Issue
相似的 Issue
-
ci-failure-cause test-failure
难度 2/5 1-3 小时 新手友好度 72/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 68/100
-
area:frontend bug FE hotspot:css mvp P3
难度 1/5 1 小时以内 新手友好度 90/100
klasolsson81/jobbliggaren#1856 ·
维护者通常 1 天内回复
-
Area: App+Library Build
难度 2/5 1-3 小时 新手友好度 72/100
维护者通常 1 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 78/100
Aaronontheweb/freshdesk-cli#148 ·