From cf5bb9f72e82087dfc06f40c3f49a9c409d032da Mon Sep 17 00:00:00 2001 From: Sal Tijerina Date: Wed, 16 Oct 2024 10:18:43 -0500 Subject: [PATCH] fix race condition where setfacl command fails bc directory does not exist (#1477) --- designsafe/apps/auth/tasks.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/designsafe/apps/auth/tasks.py b/designsafe/apps/auth/tasks.py index c4223e6f0d..1dd1a986b0 100644 --- a/designsafe/apps/auth/tasks.py +++ b/designsafe/apps/auth/tasks.py @@ -71,7 +71,7 @@ def check_or_configure_system_and_user_directory( logger.info( f"Directory for user={username} on system={system_id}/{path} exists and works. " ) - except (NotFoundError, ForbiddenError, UnauthorizedError) as e: + except (NotFoundError, ForbiddenError, UnauthorizedError): logger.info( "Ensuring directory exists for user=%s then going to run setfacl on system=%s path=%s", username, @@ -80,9 +80,11 @@ def check_or_configure_system_and_user_directory( ) tg458981_client = get_tg458981_client() - if isinstance(e, NotFoundError): - tg458981_client.files.mkdir(systemId=system_id, path=path) + # Create directory, resolves NotFoundError + tg458981_client.files.mkdir(systemId=system_id, path=path) + + # Set ACLs, resolves UnauthorizedError and ForbiddenError tg458981_client.files.setFacl( systemId=system_id, path=path,