Change the way jobs are downloaded + folder created in configs
This commit is contained in:
parent
c4bd535acc
commit
5263be27d5
|
@ -1260,7 +1260,7 @@ class Database:
|
|||
)
|
||||
}
|
||||
|
||||
def get_job_cache_file(self, job_name: str, file_name: str) -> Optional[bytes]:
|
||||
def get_job_cache_file(self, job_name: str, file_name: str) -> Optional[Any]:
|
||||
"""Get job cache file."""
|
||||
with self.__db_session() as session:
|
||||
return (
|
||||
|
|
|
@ -592,7 +592,7 @@ def configs():
|
|||
if request.form["operation"] in ("new", "edit"):
|
||||
if not app.config["CONFIGFILES"].check_name(variables["name"]):
|
||||
flash(
|
||||
f"Invalid {variables['type']} name. (Can only contain numbers, letters, underscores and hyphens (min 4 characters and max 64))",
|
||||
f"Invalid {variables['type']} name. (Can only contain numbers, letters, underscores, dots and hyphens (min 4 characters and max 64))",
|
||||
"error",
|
||||
)
|
||||
return redirect(url_for("loading", next=url_for("configs")))
|
||||
|
@ -1439,10 +1439,8 @@ def jobs_download():
|
|||
404,
|
||||
)
|
||||
|
||||
with BytesIO(cache_file) as file:
|
||||
file.seek(0)
|
||||
|
||||
return send_file(file, as_attachment=True, attachment_filename=file_name)
|
||||
file = BytesIO(cache_file.data)
|
||||
return send_file(file, as_attachment=True, download_name=file_name)
|
||||
|
||||
|
||||
@app.route("/login", methods=["GET", "POST"])
|
||||
|
|
|
@ -9,7 +9,7 @@ from utils import path_to_dict
|
|||
|
||||
class ConfigFiles:
|
||||
def __init__(self, logger, db):
|
||||
self.__name_regex = re_compile(r"^[a-zA-Z0-9_-]{1,64}$")
|
||||
self.__name_regex = re_compile(r"^[a-zA-Z0-9_\-.]{1,64}$")
|
||||
self.__root_dirs = [
|
||||
child["name"]
|
||||
for child in path_to_dict("/etc/bunkerweb/configs")["children"]
|
||||
|
@ -93,7 +93,7 @@ class ConfigFiles:
|
|||
return f"{path} was successfully deleted", 0
|
||||
|
||||
def create_folder(self, path: str, name: str) -> Tuple[str, int]:
|
||||
folder_path = join(path, name)
|
||||
folder_path = join(path, name) if not path.endswith(name) else path
|
||||
try:
|
||||
mkdir(folder_path)
|
||||
except OSError:
|
||||
|
|
|
@ -320,17 +320,9 @@ class Download {
|
|||
}
|
||||
|
||||
async sendFileToDL(jobName, fileName) {
|
||||
const response = await fetch(
|
||||
`${location.href}/jobs/download?job_name=${jobName}&file_name=${fileName}`
|
||||
window.open(
|
||||
`${location.href}/download?job_name=${jobName}&file_name=${fileName}`
|
||||
);
|
||||
|
||||
if (response.status === 200) {
|
||||
const res = await response.json();
|
||||
//last update
|
||||
return;
|
||||
} else {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue