diff --git a/access_gedi/download_gedi.py b/access_gedi/download_gedi.py index 4a28e2cfb9996e3fc477012f74847c4f4a2ccc45..5d03bba26d14497c397f04709804e182f355be3b 100644 --- a/access_gedi/download_gedi.py +++ b/access_gedi/download_gedi.py @@ -98,16 +98,19 @@ def get_gedi_data(filename: str, # Prepare the output path if not os.path.exists(target_dir): os.makedirs(target_dir) - output_path = os.path.join(target_dir, filename) - if os.path.exists(output_path): - raise FileExistsError(f"File already exists at {output_path}") - + # Get the s3 URL if not already passed if filename.startswith("s3://"): s3_url = filename + filename = os.path.basename(filename) else: s3_url = gedi_filename_to_s3_url(filename) + output_path = os.path.join(target_dir, filename) + + if os.path.exists(output_path): + raise FileExistsError(f"File already exists at {output_path}") + file_type = infer_product(filename) if file_type in ["l1b", "l2a"]: daac = 'lp'