WIP: MaterialX addon #104594
@ -29,6 +29,7 @@ from . import (
|
||||
nodes,
|
||||
matlib,
|
||||
material,
|
||||
utils,
|
||||
)
|
||||
|
||||
from . import logging
|
||||
@ -53,6 +54,8 @@ def register():
|
||||
def unregister():
|
||||
log("unregister")
|
||||
|
||||
utils.clear_temp_dir()
|
||||
|
||||
matlib.unregister()
|
||||
material.unregister()
|
||||
nodes.unregister()
|
||||
|
@ -335,6 +335,20 @@ def temp_dir():
|
||||
return d
|
||||
|
||||
|
||||
def clear_temp_dir():
|
||||
d = temp_dir()
|
||||
paths = tuple(d.iterdir())
|
||||
if not paths:
|
||||
return
|
||||
|
||||
log("Clearing temp dir", d)
|
||||
for path in paths:
|
||||
if path.is_dir():
|
||||
shutil.rmtree(path, ignore_errors=True)
|
||||
else:
|
||||
os.remove(path)
|
||||
|
||||
|
||||
def get_temp_file(suffix, name=None, is_rand=False):
|
||||
if not name:
|
||||
return Path(tempfile.mktemp(suffix, "tmp", temp_dir()))
|
||||
|
Loading…
Reference in New Issue
Block a user