Reputation: 3410
First, I created a 1GB file and transfer into /target
folder, then I compressed the file using 7z a targer.7z target
.
Later I append hello
string to the tail of the 1GB file. When I re-compressed the /target
folder using update option 7z u target.7z target
; I observe that updated file is compressed all over again instead of compressing only its updated section.
[Q] How could I force 7z
to compress only the updated section of the file instead of compressing complete updated file? is there any alternative compression methods to achieve this goal?
Example:
$ 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
Here, as you can see, I appended file with 'hello
' string, and instead of compressing 'hello's
located file-block and merge with the already compressed 1GB file, complete file has be re-compressed again.
Upvotes: 0
Views: 98
Reputation: 112502
7z is not designed for that.
You can look at the gzlog.h and gzlog.c code for an example of how to append short messages efficiently to a compressed file.
Upvotes: 1