Fix: ensure loaded path is folder and not file #104812

Closed
Daniel Grauer wants to merge 4 commits from DanielGrauer:fix-error-when-file-is-selected into main

When changing the target branch, be careful to rebase the branch in your fork to match. See documentation.
Member

The input path to load brush sets only works with a folder as path. If a file is selected in the filemanger to load the path the import fails and throws a error. To avoid the import failing, the filename is now stripped from the path to load the folder.

The input path to load brush sets only works with a folder as path. If a file is selected in the filemanger to load the path the import fails and throws a error. To avoid the import failing, the filename is now stripped from the path to load the folder.
Daniel Grauer added the
Interest
Import and Export
label 2023-08-01 16:31:20 +02:00

This solution seems to be a workaround, is it possible to solve it without this path manipulation?

Note that this code may not be completely problem-free as it depends on the specific file system (e.g. the backslash is used as a path separator on Windows, but on Unix-based systems the separator would be a forward slash "/ ").

Rather than using such a workaround, it might be better to check how the LoadBrushSet function is called and ensure that filepath is always given as a valid directory rather than relying on this path manipulation.

This solution seems to be a workaround, is it possible to solve it without this path manipulation? Note that this code may not be completely problem-free as it depends on the specific file system (e.g. the backslash is used as a path separator on Windows, but on Unix-based systems the separator would be a forward slash "/ "). Rather than using such a workaround, it might be better to check how the `LoadBrushSet` function is called and ensure that `filepath` is always given as a valid directory rather than relying on this path manipulation.
Author
Member

This solution seems to be a workaround, is it possible to solve it without this path manipulation?

Note that this code may not be completely problem-free as it depends on the specific file system (e.g. the backslash is used as a path separator on Windows, but on Unix-based systems the separator would be a forward slash "/ ").

Rather than using such a workaround, it might be better to check how the LoadBrushSet function is called and ensure that filepath is always given as a valid directory rather than relying on this path manipulation.

Thanks a lot for the feedback, i changed it in the LoadBrushSet so only directories can be loaded and removed the "workaround". I also added a filter to show only folders and images as this is what is relevant when using this importer.

> This solution seems to be a workaround, is it possible to solve it without this path manipulation? > > Note that this code may not be completely problem-free as it depends on the specific file system (e.g. the backslash is used as a path separator on Windows, but on Unix-based systems the separator would be a forward slash "/ "). > > Rather than using such a workaround, it might be better to check how the `LoadBrushSet` function is called and ensure that `filepath` is always given as a valid directory rather than relying on this path manipulation. Thanks a lot for the feedback, i changed it in the LoadBrushSet so only directories can be loaded and removed the "workaround". I also added a filter to show only folders and images as this is what is relevant when using this importer.
Daniel Grauer force-pushed fix-error-when-file-is-selected from c71ff2b3ee to 1b985c5ed7 2023-08-20 15:20:36 +02:00 Compare
Daniel Grauer closed this pull request 2023-08-22 18:50:21 +02:00

Pull request closed

Sign in to join this conversation.
No reviewers
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Reference: blender/blender-addons#104812
No description provided.