mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-02-07 11:45:24 +03:00
Update http.py
* Feedback * Formatting fixes
This commit is contained in:
parent
c24d40cc8b
commit
01ad564205
@ -1956,15 +1956,14 @@ def export_recording(camera_name: str, start_time, end_time):
|
|||||||
|
|
||||||
|
|
||||||
def export_filename_check_extension(filename: str):
|
def export_filename_check_extension(filename: str):
|
||||||
filename_split = os.path.splitext(filename)
|
if filename.endswith(".mp4"):
|
||||||
if filename_split[1] == ".mp4":
|
|
||||||
return filename
|
return filename
|
||||||
else:
|
else:
|
||||||
return filename + ".mp4"
|
return filename + ".mp4"
|
||||||
|
|
||||||
|
|
||||||
def export_filename_is_valid(filename: str):
|
def export_filename_is_valid(filename: str):
|
||||||
if re.search(r'[^.:_A-Za-z0-9]', filename) or filename.startswith('in_progress.'):
|
if re.search(r"[^:_A-Za-z0-9]", filename) or filename.startswith("in_progress."):
|
||||||
return False
|
return False
|
||||||
else:
|
else:
|
||||||
return True
|
return True
|
||||||
@ -1972,7 +1971,9 @@ def export_filename_is_valid(filename: str):
|
|||||||
|
|
||||||
@bp.route("/export/<file_name_current>/<file_name_new>", methods=["PATCH"])
|
@bp.route("/export/<file_name_current>/<file_name_new>", methods=["PATCH"])
|
||||||
def export_rename(file_name_current, file_name_new: str):
|
def export_rename(file_name_current, file_name_new: str):
|
||||||
safe_file_name_current = secure_filename(export_filename_check_extension(file_name_current))
|
safe_file_name_current = secure_filename(
|
||||||
|
export_filename_check_extension(file_name_current)
|
||||||
|
)
|
||||||
file_current = os.path.join(EXPORT_DIR, safe_file_name_current)
|
file_current = os.path.join(EXPORT_DIR, safe_file_name_current)
|
||||||
|
|
||||||
if not os.path.exists(file_current):
|
if not os.path.exists(file_current):
|
||||||
@ -1983,7 +1984,12 @@ def export_rename(file_name_current, file_name_new: str):
|
|||||||
|
|
||||||
if not export_filename_is_valid(file_name_new):
|
if not export_filename_is_valid(file_name_new):
|
||||||
return make_response(
|
return make_response(
|
||||||
jsonify({"success": False, "message": f"{file_name_new} contains illegal characters."}),
|
jsonify(
|
||||||
|
{
|
||||||
|
"success": False,
|
||||||
|
"message": f"{file_name_new} contains illegal characters.",
|
||||||
|
}
|
||||||
|
),
|
||||||
400,
|
400,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user