Bug 377421 - Ark claims to delete file from APK while it didn't
Summary: Ark claims to delete file from APK while it didn't
Status: RESOLVED FIXED
Alias: None
Product: ark
Classification: Applications
Component: general (show other bugs)
Version: 16.12.2
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: Elvis Angelaccio
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-03-09 13:30 UTC by Kai Uwe Broulik
Modified: 2017-03-13 18:32 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In: 17.04.0


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Kai Uwe Broulik 2017-03-09 13:30:47 UTC
When manually deleting files from a .apk file (I know this breaks signing and what not but I wanted to test something) it asks whether I'm really sure and then removes the file from the list.

However, it didn't actually delete the file and on re-opening the file the next time it's there again (also file size didn't change). If I just rename the file from .apk to .zip it works just fine.

Wild guess: could it be that the zip cmdline tool it uses in the background refuses because it doesn't have a "zip" file extension? In any case it should not lie to me by showing the file being succesfully deleted. ;)
Comment 1 Ragnar Thomsen 2017-03-09 17:25:53 UTC
I can't reproduce with a random apk archive from the internet. Tried with both cli7z and clizip plugins.

Can you set:
QT_LOGGING_RULES=ark.*.debug=true
and then reproduce the problem and attach console output?

Does it happen with all apk archives? If not, can you provide a link to the affected archive or upload it (if small)?

What is your version of Ark?
Comment 2 Kai Uwe Broulik 2017-03-10 09:12:47 UTC
Sorry, forgot to set the version field, version is 16.12.2.

For me it also happens with other APKs I did not create myself.

Running ark with logging enabled:

ark.main: Trying to open QUrl("file:///home/foo/test.apk")
ark.part: Attempting to open archive "/home/foo/test.apk"
ark.kerfuffle: Going to create archive "/home/foo/test.apk"
ark.kerfuffle: Mimetype for filename extension ( "application/vnd.android.package-archive" ) did not match mimetype for content ( "application/zip" ). Using content-based mimetype.
ark.kerfuffle: Checking plugin "kerfuffle_cli7z"
ark.kerfuffle: Created read-only interface for "/home/foo/test.apk"
ark.kerfuffle: Mimetype for filename extension ( "application/vnd.android.package-archive" ) did not match mimetype for content ( "application/zip" ). Using content-based mimetype.
ark.kerfuffle: Created read-write interface for "/home/foo/test.apk"
ark.cli7z: Loaded cli_7z plugin
ark.cli7z: Setting up parameters...
ark.kerfuffle: Successfully loaded plugin "kerfuffle_cli7z"
ark.kerfuffle: Created archive instance
ark.kerfuffle: LoadJob created
ark.main: Entering application loop
ark.kerfuffle: Executing "/usr/bin/7z" ("l", "-slt", "/home/foo/test.apk") within directory "/home/broulik/Projekte/kf5/plasma-workspace/build"
ark.cli7z: p7zip version "9.20" detected
ark.cli7z: Archive name:  "/home/foo/test.apk"
ark.cli7z: Archive type:  "zip"
ark.part: Showing columns:  (0, 1, 2, 3, 7, 8, 10)
ark.kerfuffle: Process finished, exitcode: 0 exitstatus: QProcess::ExitStatus(NormalExit)
ark.kerfuffle: Job finished, result: true , time: 1393 ms
ark.kerfuffle: Mimetype for filename extension ( "application/vnd.android.package-archive" ) did not match mimetype for content ( "application/zip" ). Using content-based mimetype.

*** Chose to delete a file ***

ark.kerfuffle: Going to delete 1 entries
ark.kerfuffle: Executing "/usr/bin/7z" ("d", "/home/foo/test.apk", "AndroidManifest.xml") within directory "/home/broulik/Projekte/kf5/plasma-workspace/build"
ark.kerfuffle: Process finished, exitcode: 2 exitstatus: QProcess::ExitStatus(NormalExit)
ark.kerfuffle: Job finished, result: true , time: 22 ms

File is still there. When I run the command manually I get "Error: /home/foo/test.apk is not supported archive" and an exit code of 2.
Comment 3 Ragnar Thomsen 2017-03-10 18:31:35 UTC
Ok so seems to be a problem with 7z. I noticed you're using an old version (9.20). Can you try updating to a more recent version of 7z?
Comment 4 Kai Uwe Broulik 2017-03-10 19:56:32 UTC
I'm using whatever KDE neon / its Ubuntu base provides. In any case it should handle such a scenario gracefully.
Comment 5 Ragnar Thomsen 2017-03-10 21:19:02 UTC
I can confirm that deleting files from apk-archives with 7z v9.20 doesn't work.

No problem with 7z v9.38.1 or later.
Comment 6 Ragnar Thomsen 2017-03-13 18:32:10 UTC
Git commit f8df291a061f4f6e078cb57f40bd9182b799617d by Ragnar Thomsen.
Committed on 13/03/2017 at 18:26.
Pushed by rthomsen into branch 'master'.

cli7z: Catch error from p7zip 9.20 when deleting files from APK archives

7z 9.20 does not seem to support deleting files from APK archives
(Android Application Packages) even though these are zip archives.

A new member function named readDeleteLine() was added to CliInterface.
The function is overridden in the cli7z plugin and catches the error
message from 7z when attempting to delete files.
FIXED-IN: 17.04.0
Differential Revision: D5011

M  +10   -0    kerfuffle/cliinterface.cpp
M  +1    -0    kerfuffle/cliinterface.h
M  +12   -0    plugins/cli7zplugin/cliplugin.cpp
M  +1    -0    plugins/cli7zplugin/cliplugin.h

https://commits.kde.org/ark/f8df291a061f4f6e078cb57f40bd9182b799617d