mirror of
https://github.com/clearml/clearml-server
synced 2025-03-16 02:18:43 +00:00
Fix do not return full file path on errors from the fileserver
This commit is contained in:
parent
639b3d59a4
commit
beff19e104
@ -105,14 +105,14 @@ def _get_full_path(path: str) -> Path:
|
|||||||
|
|
||||||
@app.route("/<path:path>", methods=["DELETE"])
|
@app.route("/<path:path>", methods=["DELETE"])
|
||||||
def delete(path):
|
def delete(path):
|
||||||
real_path = _get_full_path(path)
|
full_path = _get_full_path(path)
|
||||||
if not real_path.exists() or not real_path.is_file():
|
if not full_path.exists() or not full_path.is_file():
|
||||||
log.error(f"Error deleting file {str(real_path)}. Not found or not a file")
|
log.error(f"Error deleting file {str(full_path)}. Not found or not a file")
|
||||||
abort(Response(f"File {str(real_path)} not found", 404))
|
abort(Response(f"File {str(path)} not found", 404))
|
||||||
|
|
||||||
real_path.unlink()
|
full_path.unlink()
|
||||||
|
|
||||||
log.info(f"Deleted file {str(real_path)}")
|
log.info(f"Deleted file {str(full_path)}")
|
||||||
return json.dumps(str(path)), 200
|
return json.dumps(str(path)), 200
|
||||||
|
|
||||||
|
|
||||||
@ -139,17 +139,17 @@ def batch_delete():
|
|||||||
record_error("Empty path not allowed", file, path)
|
record_error("Empty path not allowed", file, path)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
path = _get_full_path(path)
|
full_path = _get_full_path(path)
|
||||||
|
|
||||||
if not path.exists():
|
if not full_path.exists():
|
||||||
record_error("Not found", file, path)
|
record_error("Not found", file, path)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if path.is_file():
|
if full_path.is_file():
|
||||||
path.unlink()
|
full_path.unlink()
|
||||||
elif path.is_dir():
|
elif full_path.is_dir():
|
||||||
shutil.rmtree(path)
|
shutil.rmtree(full_path)
|
||||||
else:
|
else:
|
||||||
record_error("Not a file or folder", file, path)
|
record_error("Not a file or folder", file, path)
|
||||||
continue
|
continue
|
||||||
@ -157,7 +157,7 @@ def batch_delete():
|
|||||||
record_error(ex.strerror, file, path)
|
record_error(ex.strerror, file, path)
|
||||||
continue
|
continue
|
||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
record_error(str(ex).replace(str(path), ""), file, path)
|
record_error(str(ex).replace(str(full_path), ""), file, path)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
deleted[file] = str(path)
|
deleted[file] = str(path)
|
||||||
|
Loading…
Reference in New Issue
Block a user