From 40b0326421eb7f3a73a7bb053ecd0d461b36f11d Mon Sep 17 00:00:00 2001 From: sam Date: Thu, 24 Aug 2023 09:19:34 +0100 Subject: [PATCH] fix: set tile_path_instance outside try, ref before assign --- src/backend/app/projects/project_crud.py | 38 ++++++++++++------------ 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/src/backend/app/projects/project_crud.py b/src/backend/app/projects/project_crud.py index f194e84ea9..5e5bc35cee 100644 --- a/src/backend/app/projects/project_crud.py +++ b/src/backend/app/projects/project_crud.py @@ -2115,26 +2115,26 @@ async def get_project_tiles( source: str, background_task_id: uuid.UUID, ): - try: - """Get the tiles for a project""" - - zooms = [12, 13, 14, 15, 16, 17, 18, 19] - source = source - tiles_path_id = uuid.uuid4() - tiles_dir = f"{TILESDIR}/{tiles_path_id}" - base = f"{tiles_dir}/{source}tiles" - outfile = f"{tiles_dir}/{project_id}_{source}tiles.mbtiles" - - if not os.path.exists(base): - os.makedirs(base) + """Get the tiles for a project.""" + zooms = [12, 13, 14, 15, 16, 17, 18, 19] + source = source + tiles_path_id = uuid.uuid4() + tiles_dir = f"{TILESDIR}/{tiles_path_id}" + base = f"{tiles_dir}/{source}tiles" + outfile = f"{tiles_dir}/{project_id}_{source}tiles.mbtiles" + + if not os.path.exists(base): + os.makedirs(base) + + tile_path_instance = db_models.DbTilesPath( + project_id="", + background_task_id=str(background_task_id), + status=1, + tile_source=source, + path=outfile, + ) - tile_path_instance = db_models.DbTilesPath( - project_id=project_id, - background_task_id=str(background_task_id), - status=1, - tile_source=source, - path=outfile, - ) + try: db.add(tile_path_instance) db.commit()