From ab3a65dee89f1c4a0c9ad9ad3abe0881f7c84d99 Mon Sep 17 00:00:00 2001 From: Eva Maxfield Brown Date: Sun, 18 Sep 2022 09:25:48 -0700 Subject: [PATCH] Use random filepaths for temp storage --- .../gcloud-functions/generate-clip/main.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/cdp_backend/infrastructure/gcloud-functions/generate-clip/main.py b/cdp_backend/infrastructure/gcloud-functions/generate-clip/main.py index bfc7a107..2b2f8552 100644 --- a/cdp_backend/infrastructure/gcloud-functions/generate-clip/main.py +++ b/cdp_backend/infrastructure/gcloud-functions/generate-clip/main.py @@ -82,12 +82,17 @@ def generate_clip(request: Request) -> Union[str, NoReturn]: logging.error("Requested clip duration exceeds allowed maximum.") return abort(400) + # Path to store the local full video + local_full_video = f"/tmp/{uuid4()}" + # Path to store the local clip + local_clip = f"/tmp/{uuid4()}" + # Download the session video try: local_video = download_video_from_session_id( credentials_file=CREDENTIALS_PATH, session_id=session_id, - dest="/tmp/full-video", + dest=local_full_video, ) except Exception as e: logging.error( @@ -101,7 +106,7 @@ def generate_clip(request: Request) -> Union[str, NoReturn]: video_filepath=Path(local_video), start_time=start_time, end_time=end_time, - output_path=Path("/tmp/clipped"), + output_path=Path(local_clip), output_format=output_format, ) except Exception as e: