Fix T61246: studiolights (un)install problems

- studiolights were not installed to their proper subfolder (thus not
recognized on blender restart)
- they were actually loaded with a wrong path which could lead to
deletion of the original source file when uninstalled again
This commit is contained in:
Philipp Oeser 2019-02-06 22:51:29 +01:00
parent 7325035e60
commit 478be344fa
Notes: blender-bot 2023-02-14 03:49:22 +01:00
Referenced by issue #61274, Duplicate current workspace makes the workspace menu disappear
Referenced by issue #61246, lookDev HDRIs deleting wrong file
1 changed files with 5 additions and 5 deletions

View File

@ -2465,15 +2465,15 @@ class WM_OT_studiolight_install(Operator):
import shutil
prefs = context.preferences
filepaths = [os.path.join(self.directory, e.name) for e in self.files]
path_studiolights = bpy.utils.user_resource('DATAFILES', "studiolights", create=True)
path_studiolights = os.path.join("studiolights", self.type.lower())
path_studiolights = bpy.utils.user_resource('DATAFILES', path_studiolights, create=True)
if not path_studiolights:
self.report({'ERROR'}, "Failed to create Studio Light path")
return {'CANCELLED'}
for filepath in filepaths:
shutil.copy(filepath, path_studiolights)
prefs.studio_lights.load(os.path.join(path_studiolights, filepath), self.type)
for e in self.files:
shutil.copy(os.path.join(self.directory, e.name), path_studiolights)
prefs.studio_lights.load(os.path.join(path_studiolights, e.name), self.type)
# print message
msg = (