Not certain if this works, but this should help finding data maybe.

This commit is contained in:
Dan 2022-02-10 16:10:35 -05:00
parent eb7760fa55
commit edaf6e205e
3 changed files with 17 additions and 2 deletions

View File

@ -32,6 +32,10 @@ class FileSystemService(object):
def category_path(name: str):
return os.path.join(FileSystemService.root_path(), name)
@staticmethod
def library_path(name: str):
return os.path.join(FileSystemService.root_path(), FileSystemService.LIBRARY_SPECS, name)
@staticmethod
def category_path_for_spec(spec):
if spec.is_master_spec:

View File

@ -51,17 +51,22 @@ class SpecFileService(FileSystemService):
SpecFileService.set_primary_bpmn(workflow_spec, file_name, binary_data)
return file
@staticmethod
def get_data(workflow_spec: WorkflowSpecInfo, file_name: str):
file_path = SpecFileService.file_path(workflow_spec, file_name)
if not os.path.exists(file_path):
# If the file isn't here, it may be in a library
for lib in workflow_spec.libraries:
lib_path = SpecFileService.library_path(lib)
file_path = SpecFileService.file_path(workflow_spec, file_name)
if os.path.exists(file_path):
break
if not os.path.exists(file_path):
raise ApiError("unknown_file", f"So file found with name {file_name} in {workflow_spec.display_name}")
with open(file_path, 'rb') as f_handle:
spec_file_data = f_handle.read()
return spec_file_data
@staticmethod
def file_path(spec: WorkflowSpecInfo, file_name: str):
return os.path.join(SpecFileService.workflow_path(spec), file_name)

View File

@ -0,0 +1,6 @@
# loop over all the categories in the database
# assure we have a directory with the correct name
# assure it contains a valid json file called categories.json
categories = db.