Skip to content

Commit

Permalink
fix path errors on data upload
Browse files Browse the repository at this point in the history
  • Loading branch information
hambsch committed Nov 7, 2024
1 parent b8ec095 commit 83c2400
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion server/guppy/endpoints/endpoint_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ def validate_layer_and_get_file_path(db: Session, layer_name: str) -> str:
if not layer:
raise HTTPException(status_code=404, detail=f"Layer not found: {layer_name}")
file_path = layer.file_path
if not os.path.exists(file_path):
if file_path and not os.path.exists(file_path):
raise HTTPException(status_code=404, detail=f"File not found: {file_path}")
if file_path.endswith('.mbtiles') and os.path.exists(layer.data_path):
file_path = layer.data_path
Expand Down
2 changes: 1 addition & 1 deletion server/guppy/endpoints/endpoints_upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def upload_file(layer_name: str, label: str, file: UploadFile, data: UploadFile

if data:
data_location, tmp_data_location = create_location_paths_and_check_if_exists(d_ext, sanitized_dataname, sanitized_layer_name, is_raster=True)
write_input_file_to_disk(data, tmp_data_location)
write_input_file_to_disk(data, data_location)

is_mbtile = create_preprocessed_layer_file(ext, file_location, sanitized_filename, sanitized_layer_name, tmp_file_location, max_zoom)

Expand Down
2 changes: 1 addition & 1 deletion server/guppy/endpoints/upload_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ def create_location_paths_and_check_if_exists(ext: str, sanitized_filename: str,
"""
if ext.lower() in ['.tif', '.tiff', '.asc', ]:
tmp_file_location = f"{cfg.deploy.content}/tifs/uploaded/{sanitized_layer_name}_{sanitized_filename}_tmp.{ext}"
tmp_file_location = f"{cfg.deploy.content}/tifs/uploaded/{sanitized_layer_name}_{sanitized_filename}_tmp{ext}"
file_location = f"{cfg.deploy.content}/tifs/uploaded/{sanitized_layer_name}_{sanitized_filename}.tif"
if os.path.exists(file_location):
raise create_error(message=f"Upload failed: File {sanitized_layer_name}_{sanitized_filename}.tif already exists.", code=400)
Expand Down

0 comments on commit 83c2400

Please sign in to comment.