[feat] add more logs, handle case of existing folder, not being a file
Browse files
wrappers/fastapi_wrapper.py
CHANGED
@@ -131,7 +131,14 @@ write_tmp_on_disk = os.getenv("WRITE_TMP_ON_DISK", "")
|
|
131 |
app_logger.info(f"write_tmp_on_disk:{write_tmp_on_disk}.")
|
132 |
if bool(write_tmp_on_disk):
|
133 |
try:
|
134 |
-
pathlib.Path
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
135 |
os.makedirs(write_tmp_on_disk, exist_ok=True)
|
136 |
app.mount("/vis_output", StaticFiles(directory=write_tmp_on_disk), name="vis_output")
|
137 |
except RuntimeError as rerr:
|
|
|
131 |
app_logger.info(f"write_tmp_on_disk:{write_tmp_on_disk}.")
|
132 |
if bool(write_tmp_on_disk):
|
133 |
try:
|
134 |
+
path_write_tmp_on_disk = pathlib.Path(write_tmp_on_disk)
|
135 |
+
try:
|
136 |
+
pathlib.Path.unlink(path_write_tmp_on_disk, missing_ok=True)
|
137 |
+
except PermissionError or OSError as err:
|
138 |
+
app_logger.error(f"{err} while removing old write_tmp_on_disk:{write_tmp_on_disk}.")
|
139 |
+
app_logger.error(f"is file?{path_write_tmp_on_disk.is_file()}.")
|
140 |
+
app_logger.error(f"is symlink?{path_write_tmp_on_disk.is_symlink()}.")
|
141 |
+
app_logger.error(f"is folder?{path_write_tmp_on_disk.is_dir()}.")
|
142 |
os.makedirs(write_tmp_on_disk, exist_ok=True)
|
143 |
app.mount("/vis_output", StaticFiles(directory=write_tmp_on_disk), name="vis_output")
|
144 |
except RuntimeError as rerr:
|