Cleanup
This commit is contained in:
@@ -17,10 +17,13 @@ def _read(event,args):
|
||||
# r+ and w+ can read; they must obey the same boundary as a plain read.
|
||||
if flags & os.O_WRONLY:return
|
||||
path=Path(os.fsdecode(name)).resolve()
|
||||
data,code,cache,reads=scope
|
||||
data,code,cache,compiled,reads=scope
|
||||
python_runtime=any(path.is_relative_to(Path(root).resolve()) for root in (sys.base_prefix,sys.prefix))
|
||||
allowed=path.is_relative_to(data) or path.is_relative_to(code) or python_runtime
|
||||
if cache and path.is_relative_to(cache):allowed=True
|
||||
# Only the content-addressed generic catalog directory is shared by roles.
|
||||
# Concrete musical caches remain confined to the requested role.
|
||||
if compiled and path.is_relative_to(compiled):allowed=True
|
||||
if not allowed:raise ValueError('Forbidden composition input: '+str(path))
|
||||
reads.add(str(path))
|
||||
|
||||
@@ -32,6 +35,7 @@ sys.addaudithook(_read)
|
||||
def composition(data,role,cache=None):
|
||||
reads=set()
|
||||
code=Path(__file__).resolve().parent
|
||||
token=ACTIVE.set((Path(data).resolve(),code,Path(cache).resolve()/role if cache else None,reads))
|
||||
token=ACTIVE.set((Path(data).resolve(),code,Path(cache).resolve()/role if cache else None,
|
||||
Path(cache).resolve()/'_resources' if cache else None,reads))
|
||||
try:yield reads
|
||||
finally:ACTIVE.reset(token)
|
||||
|
||||
Reference in New Issue
Block a user