diff --git a/main.py b/main.py index b4384c1..f3d554b 100644 --- a/main.py +++ b/main.py @@ -48,6 +48,40 @@ app.mount( name="storage_access", ) +# main.py (adicione abaixo do app.mount) + +from fastapi.responses import JSONResponse + + +# [INÍCIO DO NOVO CÓDIGO DE DIAGNÓSTICO] +@app.get( + "/api/v1/storage-check" +) # Note o prefixo /api/v1 (ou ajuste se o seu config.url for outro) +def check_storage_path(): + storage_path = "/app/storage" + + response_data = { + "diretorio_montado": storage_path, + "diretorio_existe": os.path.isdir(storage_path), + "arquivo_alvo_existe": os.path.exists( + os.path.join(storage_path, "Grantfile_jbpdy8ex.pdf") + ), + "arquivos_encontrados": [], + } + + try: + # Tenta listar o conteúdo da pasta + response_data["arquivos_encontrados"] = os.listdir(storage_path) + except FileNotFoundError: + response_data["erro_listdir"] = "Diretório não encontrado pelo Python" + except Exception as e: + response_data["erro_listdir"] = f"Erro de permissão ou outro: {e}" + + return JSONResponse(response_data) + + +# [FIM DO NOVO CÓDIGO DE DIAGNÓSTICO] + # Adiciona o middleware global de erro # app.middleware("http")(database_error_handler)