Adding to .zip archive removes file system access rules
まだ誰も着手していません。
評価
調査の方向性
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 にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- 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 ·
-
SetLevel in ZipFile オープン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
-
bug needs response
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
Adyen/adyen-dotnet-api-library#1869 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
-
difficulty/starter 🚀 good first issue kind/bug platform/ios 🍎 project/non-ui ⚙️ triage/untriaged
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
unoplatform/uno#24650 ·
-
area-ai untriaged
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
dotnet/extensions#7783 ·
-
untriaged
難易度 1/5 1時間未満 初心者へのやさしさ 88/100
dotnet/dotnet-api-docs#13095 ·