Bug 446743 - overwrite resource with different capitalization fails with "couldn't be opened as resource"
Summary: overwrite resource with different capitalization fails with "couldn't be open...
Status: RESOLVED FIXED
Alias: None
Product: krita
Classification: Applications
Component: Resource Management (show other bugs)
Version: 5.0.0-beta2
Platform: macOS (DMG) macOS
: NOR normal
Target Milestone: ---
Assignee: Dmitry Kazakov
URL:
Keywords: release_blocker
Depends on:
Blocks:
 
Reported: 2021-12-09 17:49 UTC by vanyossi
Modified: 2021-12-13 16:28 UTC (History)
3 users (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 vanyossi 2021-12-09 17:49:09 UTC
This probably is a problem only in case insensitive file systems.

Import  a brush tip i.e "brush_tip.gih"
Re-importing the same with the same capitalization updates the resource correctly
Change capitalization to "brush_TIP.gih"
overwrite dialog shows as before but the actual rewrite fails. with "The following files couldn't be opened as resources"

Only work around to update capitalization is to delete the file from resources folder.
Comment 1 wolthera 2021-12-09 17:52:13 UTC
yikes
Comment 2 amyspark 2021-12-09 18:19:29 UTC
APFS, right?
Comment 3 Dmitry Kazakov 2021-12-13 15:21:24 UTC
The bug should be fixed in this MR: https://invent.kde.org/graphics/krita/-/merge_requests/1216
Comment 4 Halla Rempt 2021-12-13 16:20:12 UTC
Git commit a4c243b1b0af33ca72e66d8819ba2bdf7486ac78 by Halla Rempt, on behalf of Dmitry Kazakov.
Committed on 13/12/2021 at 15:51.
Pushed by dkazakov into branch 'master'.

Fix md5 calculation in KisResourceLocator::importResource()

We should request MD5 from the storage instead of using the fallback
in the resource itself.
Related: bug 446588
Ref T14946

M  +2    -1    libs/resources/KisResourceLocator.cpp

https://invent.kde.org/graphics/krita/commit/a4c243b1b0af33ca72e66d8819ba2bdf7486ac78
Comment 5 Halla Rempt 2021-12-13 16:20:28 UTC
Git commit 7ceedefeac7b87bca4f52e05948c8dcbbc0f3f70 by Halla Rempt, on behalf of Dmitry Kazakov.
Committed on 13/12/2021 at 15:51.
Pushed by dkazakov into branch 'master'.

Fix importing duplicated resources that are different with case only

(on case-insensitive filesystems)

M  +4    -1    libs/resources/KisBundleStorage.cpp
M  +2    -0    libs/resources/KisFolderStorage.cpp
M  +2    -1    libs/resources/KisResourceLocator.cpp
M  +15   -0    libs/resources/KisStoragePlugin.cpp
M  +12   -0    libs/resources/KisStoragePlugin.h

https://invent.kde.org/graphics/krita/commit/7ceedefeac7b87bca4f52e05948c8dcbbc0f3f70
Comment 6 Halla Rempt 2021-12-13 16:20:36 UTC
Git commit 358bc9f1c0624a67565c0884120787140cfa7a9e by Halla Rempt, on behalf of Dmitry Kazakov.
Committed on 13/12/2021 at 15:51.
Pushed by dkazakov into branch 'master'.

Add unittests for KisResourceLocator::importResource

The requirements the tests check are the following:

1) When 'override' flag is not set we will never succeed importing,
   even when the existing resource is exactly the same. It is needed
   to avoid confusion in the models that expect the resource to be
   **added** for real.

2) When override flag is set and the exactly the same resource (with the
   same filename case, and with the latest version) exists, then we return
   this resource.

3) Otherwise we remove all the versions of the existing resource and
   add the new one.
Related: bug 446588

M  +36   -0    libs/resources/KisResourceCacheDb.cpp
M  +2    -0    libs/resources/KisResourceCacheDb.h
M  +59   -39   libs/resources/KisResourceLocator.cpp
M  +30   -0    libs/resources/tests/TestBundleStorage.cpp
M  +1    -0    libs/resources/tests/TestBundleStorage.h
M  +28   -0    libs/resources/tests/TestFolderStorage.cpp
M  +1    -0    libs/resources/tests/TestFolderStorage.h
M  +93   -0    libs/resources/tests/TestResourceLocator.cpp
M  +1    -0    libs/resources/tests/TestResourceLocator.h

https://invent.kde.org/graphics/krita/commit/358bc9f1c0624a67565c0884120787140cfa7a9e
Comment 7 Halla Rempt 2021-12-13 16:21:09 UTC
Git commit e373f57133f5935cead226567fa2ad4fab9b6bd1 by Halla Rempt, on behalf of Dmitry Kazakov.
Committed on 13/12/2021 at 15:51.
Pushed by dkazakov into branch 'master'.

Fix importing the duplicated resources

This patch also makes the import-overwrite code check consistent between
the two places where we do that, in
KisResourceUserOperations::importResourceFileWithUserInput() and in
ResourceImporter::importResources().
Related: bug 446588

M  +11   -0    libs/resources/KisResourceLocator.cpp
M  +9    -1    libs/resources/KisResourceLocator.h
M  +11   -0    libs/resources/KisResourceModel.cpp
M  +16   -0    libs/resources/KisResourceModel.h
M  +6    -0    libs/resources/KisTagFilterResourceProxyModel.cpp
M  +1    -0    libs/resources/KisTagFilterResourceProxyModel.h
M  +6    -0    libs/resources/KisTagResourceModel.cpp
M  +1    -0    libs/resources/KisTagResourceModel.h
M  +1    -9    libs/resourcewidgets/KisResourceUserOperations.cpp
M  +0    -1    libs/resourcewidgets/KisResourceUserOperations.h
M  +4    -2    plugins/extensions/resourcemanager/ResourceImporter.cpp

https://invent.kde.org/graphics/krita/commit/e373f57133f5935cead226567fa2ad4fab9b6bd1
Comment 8 Dmitry Kazakov 2021-12-13 16:28:05 UTC
Git commit e4645fe2a6601b9ab60eb17c4f5ae02430b2c2d2 by Dmitry Kazakov.
Committed on 13/12/2021 at 16:21.
Pushed by dkazakov into branch 'krita/5.0'.

Fix md5 calculation in KisResourceLocator::importResource()

We should request MD5 from the storage instead of using the fallback
in the resource itself.
Related: bug 446588
Ref T14946

M  +2    -1    libs/resources/KisResourceLocator.cpp

https://invent.kde.org/graphics/krita/commit/e4645fe2a6601b9ab60eb17c4f5ae02430b2c2d2
Comment 9 Dmitry Kazakov 2021-12-13 16:28:22 UTC
Git commit 7169111dbd98f12cf0fa6f146205dcf05061dabc by Dmitry Kazakov.
Committed on 13/12/2021 at 16:21.
Pushed by dkazakov into branch 'krita/5.0'.

Fix importing duplicated resources that are different with case only

(on case-insensitive filesystems)

M  +4    -1    libs/resources/KisBundleStorage.cpp
M  +2    -0    libs/resources/KisFolderStorage.cpp
M  +2    -1    libs/resources/KisResourceLocator.cpp
M  +15   -0    libs/resources/KisStoragePlugin.cpp
M  +12   -0    libs/resources/KisStoragePlugin.h

https://invent.kde.org/graphics/krita/commit/7169111dbd98f12cf0fa6f146205dcf05061dabc
Comment 10 Dmitry Kazakov 2021-12-13 16:28:38 UTC
Git commit 00cfb9213d53cc1b4683c912dc6e46593e4dd14f by Dmitry Kazakov.
Committed on 13/12/2021 at 16:21.
Pushed by dkazakov into branch 'krita/5.0'.

Add unittests for KisResourceLocator::importResource

The requirements the tests check are the following:

1) When 'override' flag is not set we will never succeed importing,
   even when the existing resource is exactly the same. It is needed
   to avoid confusion in the models that expect the resource to be
   **added** for real.

2) When override flag is set and the exactly the same resource (with the
   same filename case, and with the latest version) exists, then we return
   this resource.

3) Otherwise we remove all the versions of the existing resource and
   add the new one.
Related: bug 446588

M  +36   -0    libs/resources/KisResourceCacheDb.cpp
M  +2    -0    libs/resources/KisResourceCacheDb.h
M  +59   -39   libs/resources/KisResourceLocator.cpp
M  +30   -0    libs/resources/tests/TestBundleStorage.cpp
M  +1    -0    libs/resources/tests/TestBundleStorage.h
M  +28   -0    libs/resources/tests/TestFolderStorage.cpp
M  +1    -0    libs/resources/tests/TestFolderStorage.h
M  +93   -0    libs/resources/tests/TestResourceLocator.cpp
M  +1    -0    libs/resources/tests/TestResourceLocator.h

https://invent.kde.org/graphics/krita/commit/00cfb9213d53cc1b4683c912dc6e46593e4dd14f
Comment 11 Dmitry Kazakov 2021-12-13 16:28:54 UTC
Git commit 4bcf9f46b431b7785591458b42c5afcadc21c5e4 by Dmitry Kazakov.
Committed on 13/12/2021 at 16:21.
Pushed by dkazakov into branch 'krita/5.0'.

Fix importing the duplicated resources

This patch also makes the import-overwrite code check consistent between
the two places where we do that, in
KisResourceUserOperations::importResourceFileWithUserInput() and in
ResourceImporter::importResources().
Related: bug 446588

M  +11   -0    libs/resources/KisResourceLocator.cpp
M  +9    -1    libs/resources/KisResourceLocator.h
M  +11   -0    libs/resources/KisResourceModel.cpp
M  +16   -0    libs/resources/KisResourceModel.h
M  +6    -0    libs/resources/KisTagFilterResourceProxyModel.cpp
M  +1    -0    libs/resources/KisTagFilterResourceProxyModel.h
M  +6    -0    libs/resources/KisTagResourceModel.cpp
M  +1    -0    libs/resources/KisTagResourceModel.h
M  +1    -9    libs/resourcewidgets/KisResourceUserOperations.cpp
M  +0    -1    libs/resourcewidgets/KisResourceUserOperations.h
M  +4    -2    plugins/extensions/resourcemanager/ResourceImporter.cpp

https://invent.kde.org/graphics/krita/commit/4bcf9f46b431b7785591458b42c5afcadc21c5e4