libzip: Preserve modtime when extracting
ClosedPublic

Authored by rthomsen on Oct 14 2017, 4:37 PM.

Details

Summary

Qt doesnt have api for setting modtime, so we use utime().

Bug 380225

Test Plan

Extract a zip archive with libzip plugin and check that modtimes are restored for both files and folders.

Diff Detail

Repository
R36 Ark
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
rthomsen created this revision.Oct 14 2017, 4:37 PM
Restricted Application added subscribers: Ark, kde-utils-devel. · View Herald TranscriptOct 14 2017, 4:37 PM
elvisangelaccio accepted this revision.Oct 14 2017, 5:00 PM
This revision is now accepted and ready to land.Oct 14 2017, 5:00 PM
rthomsen updated this revision to Diff 20754.Oct 14 2017, 7:10 PM

Also restore mtime for directories. Since mtime for a dir gets updated when files/subfolders are added to it, we need to first save mtime for parentdir, then write the file/subfolder and finally restore the mtime for the parentdir.

rthomsen edited the test plan for this revision. (Show Details)Oct 14 2017, 7:12 PM
rthomsen edited the summary of this revision. (Show Details)
elvisangelaccio requested changes to this revision.Oct 15 2017, 4:26 PM
elvisangelaccio added inline comments.
plugins/libzipplugin/libzipplugin.cpp
549

nitpick, spaces around +

553

Use QT_STATBUF

554

Use QT_STAT. Also, the filename should be passed to QFile::encodeName().

I'm wondering if we can just use QFileInfo::lastModified() instead?

This revision now requires changes to proceed.Oct 15 2017, 4:26 PM
rthomsen updated this revision to Diff 20808.Oct 15 2017, 5:41 PM

Follow Elvis' suggestions.

rthomsen marked 3 inline comments as done.Oct 15 2017, 5:44 PM
rthomsen added inline comments.
plugins/libzipplugin/libzipplugin.cpp
554

QFileInfo::lastModified() returns a QDateTime, but we need a time_t for the utime() call.

rthomsen updated this revision to Diff 20809.Oct 15 2017, 6:05 PM
rthomsen marked an inline comment as done.

Use QFileInfo::lastModified() instead of stat().

This revision is now accepted and ready to land.Oct 16 2017, 5:23 PM
This revision was automatically updated to reflect the committed changes.