Bug 374253 - Single file/folder archives are not detected properly
Summary: Single file/folder archives are not detected properly
Status: RESOLVED FIXED
Alias: None
Product: ark
Classification: Applications
Component: general (show other bugs)
Version: 16.12.0
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: Elvis Angelaccio
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-12-28 13:54 UTC by Michal Ziabkowski
Modified: 2018-02-20 17:08 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
Archive with single file (158 bytes, application/zip)
2016-12-28 16:23 UTC, Michal Ziabkowski
Details
Archive with single folder (170 bytes, application/zip)
2016-12-28 16:24 UTC, Michal Ziabkowski
Details
working singlefolder zip (368 bytes, application/zip)
2016-12-28 16:53 UTC, Elvis Angelaccio
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Michal Ziabkowski 2016-12-28 13:54:22 UTC
After upgrading from the old KDE4-based Ark to the one based on KDE Frameworks, the single file/folder detection seems to have stopped working altogether.

Despite the "Extract to a subfolder if the archive has more than one top-level entry" option being enabled, "Extraction into subfolder" is still enabled by default when trying to extract single file/folder archives. I've been able to reproduce this with a few archive types, including 7z, rar and zip. It seems to be a general bug in the logic.

Disabling "Extract to a subfolder if the archive has more than one top-level entry" works as intended and disables subfolder extraction.

Steps to reproduce:
1) Enable "Extract to a subfolder if the archive has more than one top-level entry"
2) Open an archive containing a single file or folder
3) Click Extract

Result:
"Extraction into subfolder" is enabled, when it shouldn't

Ark 16.12.0
KDE Frameworks 5.29.0
Qt 5.7.1
Comment 1 Elvis Angelaccio 2016-12-28 15:59:55 UTC
I cannot reproduce with single folder archives, "Extraction into subfolder" is disabled if the archive has a root folder that contains everything else.
Can you attach a single-folder archive that causes this issue?

IIRC what we changed is that archives with only one file are no longer treated as single folder archives (because, well, there is no folder).
Comment 2 Michal Ziabkowski 2016-12-28 16:23:57 UTC
Created attachment 103047 [details]
Archive with single file
Comment 3 Michal Ziabkowski 2016-12-28 16:24:16 UTC
Created attachment 103048 [details]
Archive with single folder
Comment 4 Michal Ziabkowski 2016-12-28 16:26:21 UTC
I've attached two test archives. However, the bug happens with all archives I've tried.
Comment 5 Michal Ziabkowski 2016-12-28 16:44:02 UTC
Indeed, if there is a single folder with more than one file, the archive is treated as a single folder archive. If however, the folder contains only one file, it is not.

Another problem is that the configuration option doesn't mention "more than one top-level folder", but "more than one top-level entry", which covers both files and folders. At least that's one possible interpretation. So either the string should be clarified or the behavior changed in line with the description.

The crucial question is why should single file archives be treated differently than single folder ones? When extracting an archive with a single file inside, I believe  most people wouldn't expect a folder to be created. I understand this was changed for semantic reasons, but the old behavior made more sense in my opinion.
Comment 6 Elvis Angelaccio 2016-12-28 16:53:02 UTC
Created attachment 103049 [details]
working singlefolder zip

working singlefolder zip, 1 folder with 1 file, created with Ark. 

Can you test with this archive?
Comment 7 Elvis Angelaccio 2016-12-28 16:54:27 UTC
(In reply to Michal Ziabkowski from comment #5)
> Indeed, if there is a single folder with more than one file, the archive is
> treated as a single folder archive. If however, the folder contains only one
> file, it is not.

I can reproduce this only with your test file. How did you create it? 

> 
> Another problem is that the configuration option doesn't mention "more than
> one top-level folder", but "more than one top-level entry", which covers
> both files and folders. At least that's one possible interpretation. So
> either the string should be clarified or the behavior changed in line with
> the description.
> 
> The crucial question is why should single file archives be treated
> differently than single folder ones? When extracting an archive with a
> single file inside, I believe  most people wouldn't expect a folder to be
> created. I understand this was changed for semantic reasons, but the old
> behavior made more sense in my opinion.

Yes, you may argue that this is a regression and should be fixed indeed.
Comment 8 Michal Ziabkowski 2016-12-28 17:16:41 UTC
Your test archive seems to be detected properly.

My archive was created from the command line using zip v3.0:
zip test2.zip test2/test

However, a zip archive created with 7zip v16.02 also causes this bug:
7z a test2.zip test2/test

The archives in question seem to be valid. A quick file comparison reveals the structure is somewhat different for some reason.
Comment 9 Elvis Angelaccio 2017-03-05 18:14:24 UTC
Git commit a91c09d0d202fa5d8788ef3bdb85d6e7f75c061f by Elvis Angelaccio.
Committed on 05/03/2017 at 18:13.
Pushed by elvisangelaccio into branch 'master'.

Don't check 'Extraction into subfolder' with single-file archives

The ExtractionDialog only needs to know if it should enable the 'Extraction
into subfolder' groupbox, not why.
We rename `setIsSingleFolder()` to `setExtractToSubfolder()` and we call it with
`archive->hasMultipleTopLevelEntries()` as argument.
This fixes the regression with single-file archives.

Differential Revision: D3873

M  +1    -1    app/batchextract.cpp
M  +2    -4    kerfuffle/extractiondialog.cpp
M  +1    -1    kerfuffle/extractiondialog.h
M  +1    -1    part/part.cpp

https://commits.kde.org/ark/a91c09d0d202fa5d8788ef3bdb85d6e7f75c061f
Comment 10 Elvis Angelaccio 2017-03-05 20:55:29 UTC
Git commit 716e15c3c2ef122776bfa043f42f1af95fe85dbe by Elvis Angelaccio.
Committed on 05/03/2017 at 20:55.
Pushed by elvisangelaccio into branch 'master'.

Don't quick-extract to subfolders with single-file archives

This is how it used to work and what makes more sense.

Differential Revision: D4942

M  +1    -1    part/part.cpp

https://commits.kde.org/ark/716e15c3c2ef122776bfa043f42f1af95fe85dbe
Comment 11 Edmund Kasprzak 2018-02-12 22:35:49 UTC
I can confirm it's working correctly now.
Used attached zips from ticket and also few created by myself.

Neon Git Stable, Plasma 5.12.0, KF 5.43.0, Qt 5.9.3, Ark 17.12.2
Comment 12 Patrick Silva 2018-02-20 17:08:51 UTC
ark 17.12.2 also works as expected on Arch Linux.