KIso: Fixed file offsets of the underlying IO device
ClosedPublic

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

Details

Summary

The patch is proposed by Theo <alpha0x89@yahoo.de>.

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

[1] http://doc.qt.io/qt-5/qiodevice.html#seek

Test Plan

Example iso: https://sourceforge.net/projects/supergrub2/files/1.30/
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

Repository
R167 Krusader
Lint
Automatic diff as part of commit; lint not applicable.
Unit
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 https://bugs.freedesktop.org/show_bug.cgi?id=106330 by editing

/usr/share/mime/packages/freedesktop.org.xml

in order to manually apply the appropiate changes of https://cgit.freedesktop.org/xdg/shared-mime-info/commit/?id=7c7f84e2a77f4142cf77ebdf239deaa14c842f9c 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"/>
</mime-type>

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.