Skip to content

Allow passing QIODevice::Truncate in open mode

Carsten Hartenfels requested to merge hartenfels/karchive:master into master

To KCompressionDevice. This will open the underlying file with the mode, but not pass it onto the filters, which only either handle ReadOnly or WriteOnly.

On most operating systems, passing the Truncate flag is redundant, but on Android it's (unfortunately) not. If you don't pass Truncate there, the file will retain its prior contents and, if you write a file that's shorter than the existing one, will leave garbage at the end. Which breaks file formats like ZIP, which put pertinent information at the end.

The issue is also present in KF5, this patch should backport fine.

Merge request reports