Properly handle locked RAR archives
ClosedPublic

Authored by rthomsen on Mar 30 2019, 11:48 AM.

Details

Summary

RAR archives can have a "locked" property essentially making them readonly. Currently, Ark doesn't handle this properly and fails silently if the user tries to modify the archive (e.g. adding files).

See bug 368851. Note that the archive mentioned in this bug opens as readonly due the file permissions being 400.

This diff adds a virtual method ReadOnlyArchiveInterface::isLocked() with a default implementation returning false. The method is overridden by the RAR plugin which checks if the archive is locked when listing. ReadWriteArchiveInterface::isReadOnly() checks isLocked() when determining the readonly status of the archive.

Currently, the user is not notified that the archive is locked. Maybe this should be exposed somewhere in the GUI.

Test Plan

Open a locked RAR archive using the clirar plugin, e.g. the one in bug 368851. Make sure the user has write permission to the archive and verify that the archive is opened as readonly.

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.Mar 30 2019, 11:48 AM
Restricted Application added subscribers: Ark, kde-utils-devel. · View Herald TranscriptMar 30 2019, 11:48 AM
rthomsen requested review of this revision.Mar 30 2019, 11:48 AM

@rthomsen Is it possible to add a small test archive so that we can write an unit test?

rthomsen updated this revision to Diff 55114.Mar 31 2019, 9:01 AM

Add unittest.

I cannot open the test file...

Mimetype for filename extension ( "application/vnd.rar" ) did not match mimetype for content ( "application/x-zerosize" ). Using content-based mimetype.
plugins/clirarplugin/cliplugin.cpp
579

This change looks unrelated. Can we move it to another commit?

rthomsen updated this revision to Diff 55122.Mar 31 2019, 11:31 AM

Remove unrelated change.

rthomsen marked an inline comment as done.Mar 31 2019, 11:32 AM
rthomsen added inline comments.
plugins/clirarplugin/cliplugin.cpp
579

Yes, this was unrelated. Sorry.

rthomsen marked an inline comment as done.Mar 31 2019, 11:33 AM

Test file:

I cannot open the test file...

Mimetype for filename extension ( "application/vnd.rar" ) did not match mimetype for content ( "application/x-zerosize" ). Using content-based mimetype.

Maybe because I dont use arcanist. I attached the file in Phabricator.

elvisangelaccio added inline comments.Apr 6 2019, 5:06 PM
kerfuffle/archiveinterface.h
208

This could maybe be public if one day we decide to expose this info in the UI?

rthomsen updated this revision to Diff 55596.Apr 6 2019, 8:53 PM

Make ReadOnlyArchiveInterface::isLocked() public.

rthomsen marked an inline comment as done.Apr 6 2019, 8:53 PM
elvisangelaccio accepted this revision.Apr 7 2019, 11:04 AM
This revision is now accepted and ready to land.Apr 7 2019, 11:04 AM
This revision was automatically updated to reflect the committed changes.