Bug 443907 - Bundle created in beta2 can have different filenames in manifest and in actual bundle archive
Summary: Bundle created in beta2 can have different filenames in manifest and in actua...
Status: RESOLVED FIXED
Alias: None
Product: krita
Classification: Applications
Component: Resource Management (show other bugs)
Version: 5.0.0-beta2
Platform: Mint (Ubuntu based) Linux
: NOR normal
Target Milestone: ---
Assignee: Tiar
URL:
Keywords: regression, release_blocker
Depends on:
Blocks:
 
Reported: 2021-10-17 19:42 UTC by Tiar
Modified: 2021-11-02 17:37 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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