diff --git a/octoprint_klipper/__init__.py b/octoprint_klipper/__init__.py index 31d4fd1..732ebbc 100644 --- a/octoprint_klipper/__init__.py +++ b/octoprint_klipper/__init__.py @@ -446,11 +446,11 @@ class KlipperPlugin( bak_path = os.path.join(self.get_plugin_data_folder(), "configs", "") return [ - (r"/download/(.*)", LargeResponseHandler, dict(path=configpath, + (r"/download/configs/(.*)", LargeResponseHandler, dict(path=configpath, as_attachment=True, path_validation=path_validation_factory(lambda path: not is_hidden_path(path), status_code=404))), - (r"/download/backup(.*)", LargeResponseHandler, dict(path=bak_path, + (r"/download/backup/(.*)", LargeResponseHandler, dict(path=bak_path, as_attachment=True, path_validation=path_validation_factory(lambda path: not is_hidden_path(path), status_code=404))) diff --git a/octoprint_klipper/cfgUtils.py b/octoprint_klipper/cfgUtils.py index ffef145..0126acf 100644 --- a/octoprint_klipper/cfgUtils.py +++ b/octoprint_klipper/cfgUtils.py @@ -39,14 +39,16 @@ def list_cfg_files(self, path: str) -> list: for f in cfg_files: filesize = os.path.getsize(f) filemdate = time.localtime(os.path.getmtime(f)) + if path != "backup": + url = flask.url_for("index") + "plugin/klipper/download/configs/" + os.path.basename(f) + else: + url = flask.url_for("index") + "plugin/klipper/download/backup/" + os.path.basename(f) files.append(dict( - name=os.path.basename(f), - file=f, - size=" ({:.1f} KB)".format(filesize / 1000.0), - mdate=time.strftime("%d.%m.%Y %H:%M", filemdate), - url= flask.url_for("index") - + "plugin/klipper/download/" - + os.path.basename(f), + name= os.path.basename(f), + file= f, + size= " ({:.1f} KB)".format(filesize / 1000.0), + mdate= time.strftime("%d.%m.%Y %H:%M", filemdate), + url= url, )) logger.log_debug(self, "list_cfg_files " + str(len(files)) + ": " + f) return files diff --git a/octoprint_klipper/templates/klipper_backups_dialog.jinja2 b/octoprint_klipper/templates/klipper_backups_dialog.jinja2 index 9c023d2..2d87eea 100644 --- a/octoprint_klipper/templates/klipper_backups_dialog.jinja2 +++ b/octoprint_klipper/templates/klipper_backups_dialog.jinja2 @@ -61,9 +61,12 @@  |  -  |  + +  |