From 193165c855329f47edd2d6a927a01c92606f1daa Mon Sep 17 00:00:00 2001 From: maxsibilla Date: Tue, 17 Oct 2023 15:29:00 -0400 Subject: [PATCH 1/3] Adding check that the directory specified is actually a directory --- src/routes/entity_CRUD/__init__.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/routes/entity_CRUD/__init__.py b/src/routes/entity_CRUD/__init__.py index ec5026c3..fe644326 100644 --- a/src/routes/entity_CRUD/__init__.py +++ b/src/routes/entity_CRUD/__init__.py @@ -105,6 +105,8 @@ def multiple_components(): if 'dataset_link_abs_dir' in dataset: if not os.path.exists(dataset['dataset_link_abs_dir']): return Response(f"The filepath specified with 'dataset_link_abs_dir' does not exist: {dataset['dataset_link_abs_dir']}", 500) + if not os.path.isdir(dataset['dataset_link_abs_dir']): + return Response(f"The filepath specified with 'dataset_link_abs_dir is not a directory: {dataset['dataset_link_abs_dir']}", 500) else: return Response("Required field 'dataset_link_abs_dir' is missing from dataset", 500) From f3b5b7ee4f0856f18c3704a789bf5136b487e00c Mon Sep 17 00:00:00 2001 From: maxsibilla Date: Wed, 18 Oct 2023 16:14:39 -0400 Subject: [PATCH 2/3] Updating symlink call to use make_directory --- src/routes/entity_CRUD/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/routes/entity_CRUD/__init__.py b/src/routes/entity_CRUD/__init__.py index fe644326..a57ae5cf 100644 --- a/src/routes/entity_CRUD/__init__.py +++ b/src/routes/entity_CRUD/__init__.py @@ -85,7 +85,6 @@ def create_dataset(): def multiple_components(): if not request.is_json: return Response("json request required", 400) - entity_type = 'dataset' try: component_request = request.json auth_helper = AuthHelper.configured_instance(current_app.config['APP_CLIENT_ID'], current_app.config['APP_CLIENT_SECRET']) @@ -130,7 +129,8 @@ def multiple_components(): new_directory_path = ingest_helper.get_dataset_directory_absolute_path(dataset, requested_group_uuid, dataset['uuid']) logger.info( f"Creating a directory as: {new_directory_path} with a symbolic link to: {dataset['dataset_link_abs_dir']}") - os.symlink(dataset['dataset_link_abs_dir'], new_directory_path, True) + # os.symlink(dataset['dataset_link_abs_dir'], new_directory_path, True) + ingest_helper.make_directory(new_directory_path, dataset['dataset_link_abs_dir']) else: return Response("Required field 'dataset_link_abs_dir' is missing from dataset", 500) From 2e1c54dcec76d679db9fd12b053fa66c1cabda69 Mon Sep 17 00:00:00 2001 From: maxsibilla Date: Wed, 18 Oct 2023 17:40:58 -0400 Subject: [PATCH 3/3] Creating file directory before creating symlink --- src/routes/entity_CRUD/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/routes/entity_CRUD/__init__.py b/src/routes/entity_CRUD/__init__.py index a57ae5cf..2790327c 100644 --- a/src/routes/entity_CRUD/__init__.py +++ b/src/routes/entity_CRUD/__init__.py @@ -129,8 +129,8 @@ def multiple_components(): new_directory_path = ingest_helper.get_dataset_directory_absolute_path(dataset, requested_group_uuid, dataset['uuid']) logger.info( f"Creating a directory as: {new_directory_path} with a symbolic link to: {dataset['dataset_link_abs_dir']}") - # os.symlink(dataset['dataset_link_abs_dir'], new_directory_path, True) - ingest_helper.make_directory(new_directory_path, dataset['dataset_link_abs_dir']) + os.makedirs(new_directory_path) + os.symlink(dataset['dataset_link_abs_dir'], new_directory_path, True) else: return Response("Required field 'dataset_link_abs_dir' is missing from dataset", 500)