`7z` 可以只压缩文件的更新部分而不是压缩完整的更新文件吗?

Can `7z` compress only the updated section of the file instead of compressing complete updated file?

首先,我创建了一个 1GB 的文件并传输到 /target 文件夹中,然后我使用 7z a targer.7z target 压缩了该文件。

稍后我将 hello 字符串附加到 1GB 文件的尾部。当我使用更新选项 7z u target.7z target 重新压缩 /target 文件夹时;我观察到更新的文件被重新压缩,而不是只压缩其更新的部分。

[Q] 我如何强制 7z 只压缩文件的更新部分而不是压缩完整的更新文件?有没有其他压缩方法可以实现这个目标?

示例:

$ mkdir target
$ fallocate -l 1G target/temp_1GB_file
$ time 7z a target.7z target
7-Zip [64] 9.20  Copyright (c) 1999-2010 Igor Pavlov  2010-11-18
p7zip Version 9.20 (locale=en_US.UTF-8,Utf16=on,HugeFiles=on,8 CPUs)    
Scanning    
Updating archive target.7z    
Compressing  target/temp_1GB_file
Compressing  target/target.7z    
Everything is Ok

real    0m23.054s
user    0m30.316s
sys 0m1.047s

$ echo 'hello' >> target/temp_1GB_file
$ time 7z u target.7z target # Here complete file has been compressed all over again.
7-Zip [64] 9.20  Copyright (c) 1999-2010 Igor Pavlov  2010-11-18
p7zip Version 9.20 (locale=en_US.UTF-8,Utf16=on,HugeFiles=on,8 CPUs)    
Scanning   
Updating archive target.7z    
Compressing  target/temp_1GB_file    
Everything is Ok    

real    0m23.861s
user    0m30.781s
sys 0m1.192s

在这里,如您所见,我在文件中附加了 'hello' 字符串,而不是压缩 'hello's 定位的文件块并与已经压缩的 1GB 文件合并,完整文件又重新压缩了

7z 不是为此设计的。

您可以查看 gzlog.h and gzlog.c 代码,了解如何有效地将短消息附加到压缩文件的示例。