如何在tarball中覆盖一个文件

huangapple go评论87阅读模式
英文:

How to overwrite a file in a tarball

问题

我有一个特殊情况,两个文件具有相同的名称但内容不同,并且被写入同一个tar压缩包。这导致tar压缩包中存在两个条目。我想知道是否有办法让tar在压缩包中已存在同名文件时覆盖它,而不是创建另一个同名文件。

英文:

I've got an edge case where two files have the same name but different contents and are written to the same tarball. This causes there to be two entries in the tarball. I'm wondering if there's anything I can do to make the tar overwrite the file if it already exists in the tarball as opposed to creating another file with the same name.

答案1

得分: 0

第一个文件已经在你要求写第二个文件时被写入,并且流已经前进到了下一个位置,所以无法实现。请记住,tar文件是按顺序访问的。

在开始写入之前,你应该进行去重操作。

英文:

No way as the first file have already been written when you ask to write the second one and the stream has advanced the position. Remember tar files are sequentially accessed.

You should do deduplication before starting to write.

huangapple
  • 本文由 发表于 2017年3月9日 06:12:06
  • 转载请务必保留本文链接:https://go.coder-hub.com/42682882.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定