Bug 435001 - Ark does not preserve user generated xattrs (extended attributes) when editing/updating/saving a .zip file (and other types of archives)
Summary: Ark does not preserve user generated xattrs (extended attributes) when editin...
Status: RESOLVED FIXED
Alias: None
Product: ark
Classification: Applications
Component: general (show other bugs)
Version: unspecified
Platform: Other Linux
: NOR major
Target Milestone: ---
Assignee: Elvis Angelaccio
URL:
Keywords: bounty
Depends on:
Blocks:
 
Reported: 2021-03-27 04:51 UTC by funkybomber
Modified: 2024-01-13 14:43 UTC (History)
7 users (show)

See Also:
Latest Commit:
Version Fixed In: 24.02


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description funkybomber 2021-03-27 04:51:07 UTC
SUMMARY
Ark does not preserve user generated xattrs (extended attributes) when editing/updating/saving a file.

STEPS TO REPRODUCE
1. Create a new TEST.zip file
--- You can do this by selecting any file in your home directory, right clicking on it and selecting from the menu: "Compress"->"Here (as ZIP)"
2. Assign some user generated xattrs (such as Tags, Rating, Comment) to the TEST.zip file
--- You can do this by right clicking on the new TEST.zip file, select "Properties" from the menu, click the "Details" tab, and click on "Add..." to select one of the existing tags or to type in a new tag. After the first tag has been added, you can also click on "Edit..." to add/select extra tags. Click Ok. Now our TEST.zip file should have user generated xattrs.
3. Edit/update/save the TEST.zip file
--- You can do this by adding another file in the TEST.zip file. Open the TEST.zip file using Ark. Then select a new file from your home directory and drag'n'drop it into Ark. The TEST.zip file should now contain *two* compressed files. Close Ark.
4. After the above action (which triggered an edit/update/save of the TEST.zip), the user generated xattrs of the TEST.zip have disappeared!  <-- This is an undesired behaviour. (bug)

OBSERVED RESULT
Following the above steps, the user generated xattrs of the TEST.zip file disappear.

EXPECTED RESULT
The user generated xattrs of the TEST.zip should be preserved in all edit/update/save scenarios.

SOFTWARE/OS VERSIONS
Linux/KDE Plasma: 
Ark: 21.03.80
KDE Plasma Version: 5.21.3
KDE Frameworks Version: 5.81
Qt Version: 5.15.2

ADDITIONAL INFORMATION
Extension of the old bug:
https://bugs.kde.org/show_bug.cgi?id=116617
Comment 1 funkybomber 2023-12-09 11:38:46 UTC
This bug is still present in the latest KDE Neon Unstable edition. I would like to offer a bounty of $200 (USD) to fix this.
This will also be posted in the KDE forum under "Sponsored Work":
https://discuss.kde.org/t/about-the-sponsored-work-category/5358

Last tested under:

SOFTWARE/OS VERSIONS
KDE Plasma Version: 5.90.90
KDE Frameworks Version: 5.264.0
Qt Version: 6.6.0
Kernel version: 6.2.0-37-generic (64-bit)
Graphics Platform: Wayland

Tested in a Virtual Machine (in QEMU v4.0.0) with the following specs:
Processor: 2 × Intel® Core™ i3-4150 CPU @ 3.50GHz
Memory: 3.8 GiB of RAM
Graphics Processor: llvmpipe
Manufacturer: QEMU
Product name: Standard PC (Q35 + ICH9, 2009)
System version: pc-q35-6.2
Comment 3 tagwerk19 2023-12-09 13:30:40 UTC
A gradual process, fixing one application after another...

For Gwenview, see Bug 431146
Comment 4 Bug Janitor Service 2023-12-12 22:32:31 UTC
A possibly relevant merge request was started @ https://invent.kde.org/utilities/ark/-/merge_requests/219
Comment 5 Kristen McWilliam 2023-12-13 22:01:19 UTC
In the linked merge request I have fixed this issue for the following scenarios:

- Adding files to the archive
- Copying files within the archive
- Deleting / removing files from the archive
- Encrypting the archive
- Moving files within the archive

For all of these situations the metadata is now preserved. Are you aware of any other operations that cause the metadata to be lost?
Comment 6 funkybomber 2023-12-13 22:16:20 UTC
(In reply to Kristen McWilliam from comment #5)
> In the linked merge request I have fixed this issue for the following
> scenarios:
> 
> - Adding files to the archive
> - Copying files within the archive
> - Deleting / removing files from the archive
> - Encrypting the archive
> - Moving files within the archive
> 
> For all of these situations the metadata is now preserved. Are you aware of
> any other operations that cause the metadata to be lost?

Thanks for working on this! :) 
I think you should also look into the "Rename file within the archive" scenario. This also causes loss of xattrs.
Comment 7 funkybomber 2023-12-13 22:24:52 UTC
Please also note that xattrs are also lost in operations involving *folders*

I recommend you look into:
Adding folders in the archive (you can test with empty ones)
Moving folders within the archive (so that they become subfolders)
Removing folders from the archive
Renaming folders within the archive

Basically whatever action results in a different file/folder structure within the archive will result in a loss of xattrs.
Comment 8 Kristen McWilliam 2023-12-14 00:39:54 UTC
I am happy to report that all of these scenarios are also covered by the current changes. :)
Comment 9 funkybomber 2023-12-14 00:45:06 UTC
(In reply to Kristen McWilliam from comment #8)
> I am happy to report that all of these scenarios are also covered by the
> current changes. :)

That's great news! Has it been merged into Unstable already? If it has I will give it a try later today.
Would you like to send me your details & preferred method of payment for the bounty? Cheers!
Comment 10 Kristen McWilliam 2023-12-14 01:42:34 UTC
It hasn't been merged yet, it still needs a review first. I will let you know when it is so you can test it out. :)
Comment 11 Nicolas Fella 2024-01-09 00:52:13 UTC
Git commit 2b1e0a83abc7523df83513ad997a3e3489f30748 by Nicolas Fella, on behalf of Kristen McWilliam.
Committed on 09/01/2024 at 00:55.
Pushed by nicolasfella into branch 'master'.

fix: preserve archive metadata during operations

Currently metadata on an archive is lost when it is modified by Ark.
This change ensures that metadata is preserved during operations.

M  +1    -0    .kde-ci.yml
M  +1    -0    CMakeLists.txt
M  +1    -0    autotests/kerfuffle/CMakeLists.txt
A  +-    --    autotests/kerfuffle/data/archive-with-metadata.zip
A  +237  -0    autotests/kerfuffle/preservemetadatatest.cpp     [License: BSD]
M  +2    -0    kerfuffle/CMakeLists.txt
M  +27   -0    kerfuffle/archive_kerfuffle.cpp
M  +14   -0    kerfuffle/archive_kerfuffle.h
A  +43   -0    kerfuffle/metadatabackup.cpp     [License: BSD]
A  +51   -0    kerfuffle/metadatabackup.h     [License: BSD]

https://invent.kde.org/utilities/ark/-/commit/2b1e0a83abc7523df83513ad997a3e3489f30748
Comment 12 funkybomber 2024-01-13 14:43:27 UTC
The patch was tested and confirmed working in the flatpak nightly. 
The bounty has been paid to the developer.