You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There is currently no way to compress an file.tar into file.tar.gz by only adding the .gz part, ouch will detect two extensions, tar and gz, repeating the .tar process for that file that was already in that format.
So basically, ouch compress file.tar.gz file.tar.gz.xz generates a file of format .tar.gz.tar.gz.xz, instead of .tar.gz.xz.
The text was updated successfully, but these errors were encountered:
I have already thought about a solution for this, here is some pseudocode:
Assume ouch was called like this:
ouch compress file.tar.gz file.tar.gz.xz
We correctly check if it's compressing only one file, as this check additional check does not make sense when creating archives.
Then we can run the function to detect the extensions of both files.
input : [Tar, Gz] output: [Tar, Gz, Xz]
Now we check if the input extensions are a sublist of the output extensions (and at the start).
let input_extensions_are_included_in_output_extensions =
input_extensions.len() < output_extensions.len()
&& input_extensions.iter().zip(&output_extensions).all(|(a, b)| a == b);
In this case, instead of passing the output_extensions normally to the compress function, we drop the first N elements.
// Remove the first N elements efficientlylet drain_iter = output_extensions.drain(..input_extensions.len());drop(drain_iter);// [Tar, Gz, Xz] -> [Xz]
Now use the output_extensions and only compress file with the remaning Xz.
marcospb19
changed the title
Add compression format on top of files that are already compressed
Properly compress files which are already compressed
Oct 1, 2021
marcospb19
changed the title
Properly compress files which are already compressed
Properly compress files which are already partially compressed
Oct 7, 2021
There is currently no way to compress an
file.tar
intofile.tar.gz
by only adding the.gz
part,ouch
will detect two extensions,tar
andgz
, repeating the.tar
process for that file that was already in that format.So basically,
ouch compress file.tar.gz file.tar.gz.xz
generates a file of format.tar.gz.tar.gz.xz
, instead of.tar.gz.xz
.The text was updated successfully, but these errors were encountered: