Bug 443907

Summary: Bundle created in beta2 can have different filenames in manifest and in actual bundle archive
Product: [Applications] krita Reporter: Tiar <tamtamy.tymona>
Component: Resource ManagementAssignee: Tiar <tamtamy.tymona>
Status: RESOLVED FIXED    
Severity: normal CC: halla
Priority: NOR Keywords: regression, release_blocker
Version: 5.0.0-beta2   
Target Milestone: ---   
Platform: Mint (Ubuntu based)   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:

Description Tiar 2021-10-17 19:42:53 UTC
SUMMARY
Ramon gave me a bundle that he struggled to get working, and it turned out that there were two issues, both related to the way bundle saves filenames to manifest.
1) Manifest's filenames all contain `_` while filenames for the files inside the archive sometimes have spaces. It seems like while saving to manifest, all filenames are converted to only contains `_`, but saving to the archive doesn't apply the same converting,
2) Patterns get the `.pat` suffix in the manifest even if they already have a suffix, and yes, they are saved to the bundle archive without that additional suffix (which is correct, because with the additional suffix they can crash Krita, see bug 443904).

NOTE: Ramon said the bundle was created using beta2.

STEPS TO REPRODUCE (not tested, but it's assumed that's what happened)
1. Have a PNG pattern file.
2. Create a new brush preset with spaces in the name (you can't use existing ones because they already have all spaces converted to "_" in filenames).
3. Make a bundle out of them

OBSERVED RESULT
Manifest have all png files with `.png.pat` ending instead of just `.pat`.
Manifest have all resources with `_` instead of spaces.
The bundle itself, if you unzip it, have patterns with `.png` endings and brush presets with spaces in the filenames.
Krita cannot find neither those brush presets nor the patterns.
- If you rename brush presets to contain only `_` (to match the manifest), the brush presets will be read on next start of Krita.
- If you rename the pattern file to have `.png.pat`, it won't work. But if you edit the manifest to match the pattern file name (with the `.pat`), it will work.

EXPECTED RESULT
Bundle files filenames match the filenames written in the manifest.
Comment 1 Tiar 2021-11-02 16:04:06 UTC
Git commit 98e18caf45692da861924886a3f5d5d32f808342 by Agata Cacko.
Committed on 02/11/2021 at 16:03.
Pushed by tymond into branch 'master'.

Fix saving to bundle

Before this commit, bundle saving code would operate only on
filenames, but the dlg_create_bundle code changed that filename
to be something else. So the bundle would save with different filename
in the manifest and different actual filename.
This commit introduces two new parameters to the KoResourceManifest
(no new things are added to the actual manifest file in a bundle)
that are resourceId and filenameInBundle.

The first one ensures the first resource the bundle will be looking for
is the one with the same resouce id, if it's available.
The second one helps sanitizing the filename in the newly created bundle
while still allowing the manifest to point to the correct file.

M  +15   -6    libs/resources/KoResourceBundle.cpp
M  +1    -1    libs/resources/KoResourceBundle.h
M  +4    -4    libs/resources/KoResourceBundleManifest.cpp
M  +9    -2    libs/resources/KoResourceBundleManifest.h
M  +22   -1    plugins/extensions/resourcemanager/dlg_create_bundle.cpp
M  +2    -0    plugins/extensions/resourcemanager/dlg_create_bundle.h

https://invent.kde.org/graphics/krita/commit/98e18caf45692da861924886a3f5d5d32f808342
Comment 2 Tiar 2021-11-02 17:37:04 UTC
Git commit 286af7f95dba2d17ea95a269d9d27717f49480ef by Agata Cacko.
Committed on 02/11/2021 at 17:35.
Pushed by tymond into branch 'krita/5.0'.

Fix saving to bundle

Before this commit, bundle saving code would operate only on
filenames, but the dlg_create_bundle code changed that filename
to be something else. So the bundle would save with different filename
in the manifest and different actual filename.
This commit introduces two new parameters to the KoResourceManifest
(no new things are added to the actual manifest file in a bundle)
that are resourceId and filenameInBundle.

The first one ensures the first resource the bundle will be looking for
is the one with the same resouce id, if it's available.
The second one helps sanitizing the filename in the newly created bundle
while still allowing the manifest to point to the correct file.

M  +15   -6    libs/resources/KoResourceBundle.cpp
M  +1    -1    libs/resources/KoResourceBundle.h
M  +4    -4    libs/resources/KoResourceBundleManifest.cpp
M  +9    -2    libs/resources/KoResourceBundleManifest.h
M  +22   -1    plugins/extensions/resourcemanager/dlg_create_bundle.cpp
M  +2    -0    plugins/extensions/resourcemanager/dlg_create_bundle.h

https://invent.kde.org/graphics/krita/commit/286af7f95dba2d17ea95a269d9d27717f49480ef