KIso: Fixed file offsets of the underlying IO device

Authored by nmel on Jun 20 2018, 7:20 AM.



The patch is proposed by Theo <>.

kio_iso uses KArchive's KCompressionDevice to access the ISO file.
The device is created in KIso::prepareDevice and KCompressionDevice's
constructor creates a QIODevice and a QFileDevice. The corresponding
*Private devices have separate sets of member variables 'pos' and
'devicePos' that get out of sync when the QFileDevice is closed at the end
of KIso::openArchive. The QFileDevice is reset to offset zero while
QIODevice keeps the offset positions it has after reading the ISO file
system. When the ISO file is opened for reading the file data,
QFileDevice's offset positions are treated as if they haven't been reset
and subsequent seeks fall short of the requested offset.

The workaround is suggested by Qt documentation [1]
"When subclassing QIODevice, you must call QIODevice::seek() at the start
of your function to ensure integrity with QIODevice's built-in buffer."

For more details see the discussion in the bug.

FIXED: [ 372023 ] ISO files listing/extracting broken
BUG: 372023


Test Plan

Example iso:
Try browsing various iso, watch missing files/dirs and F3 on files. Previously F3 return garbled text on text files, now it's fine (I checked in my testing env).
More info is in the bug discussion.

Diff Detail

R167 Krusader
Automatic diff as part of commit; lint not applicable.
Automatic diff as part of commit; unit tests not applicable.
nmel requested review of this revision.Jun 20 2018, 7:20 AM
nmel created this revision.
asensi accepted this revision as: asensi.Jun 20 2018, 2:54 PM
asensi added a subscriber: asensi.

Thank you all! For my part, using Kubuntu 18.04: my performed tests went alright; some files (inside an iso file) that could not be seen, now can be seen correctly. Other people can do their checks.

If it may be useful for anyone: previously I had to workaround the bug by editing


in order to manually apply the appropiate changes of that (at least in my case) were:

    <comment xml:lang="zh_TW">STL 3D 模型 (二進位)</comment>
-    <magic priority="10">
-    <match value="0x0" type="byte" offset="134" mask="0xFFFF">
-        <match value="0x0" type="byte" offset="184" mask="0xFFFF">
-        <match value="0x0" type="byte" offset="234" mask="0xFFFF"/>
-        </match>
-    </match>
-    </magic>
    <glob pattern="*.stl"/>

and executing later

sudo update-mime-database /usr/share/mime
This revision is now accepted and ready to land.Jun 20 2018, 2:54 PM
nmel added a comment.Jun 22 2018, 7:49 AM

Thanks for the review and useful tips, Toni!

This revision was automatically updated to reflect the committed changes.