StudioLight: remove caches when removing studiolight

Cache files were not deleted and when uploading a new file with the same
name resulted in using the old cache file.
This commit is contained in:
2018-06-22 12:30:27 +02:00
parent e402c36388
commit 0427eca2a6
2 changed files with 45 additions and 5 deletions

View File

@@ -2478,16 +2478,20 @@ class WM_OT_studiolight_uninstall(Operator):
bl_label = "Uninstall Studio Light"
index = bpy.props.IntProperty()
def _remove_path(self, path):
if path.exists():
path.unlink()
def execute(self, context):
import pathlib
userpref = context.user_preferences
for studio_light in userpref.studio_lights:
if studio_light.index == self.index:
path = pathlib.Path(studio_light.path)
if path.exists():
path.unlink()
userpref.studio_lights_refresh()
return {'FINISHED'}
self._remove_path(pathlib.Path(studio_light.path))
self._remove_path(pathlib.Path(studio_light.path_irr_cache))
self._remove_path(pathlib.Path(studio_light.path_sh_cache))
userpref.studio_lights_refresh()
return {'FINISHED'}
return {'CANCELLED'}