From 2e8d1048649462640645848b0be054c63b11ba77 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Fri, 8 Jul 2016 10:42:50 +0200 Subject: [PATCH] Fix resource URLs for files in folders --- src/octoprint/filemanager/storage.py | 6 +++++- src/octoprint/server/api/files.py | 4 ++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/octoprint/filemanager/storage.py b/src/octoprint/filemanager/storage.py index bf0af565..62a5a0d5 100644 --- a/src/octoprint/filemanager/storage.py +++ b/src/octoprint/filemanager/storage.py @@ -490,9 +490,13 @@ class LocalFileStorage(StorageInterface): def list_files(self, path=None, filter=None, recursive=True): if path: path = self.sanitize_path(path) + base = self.path_in_storage(path) + if base: + base += "/" else: path = self.basefolder - return self._list_folder(path, filter=filter, recursive=recursive) + base = "" + return self._list_folder(path, base=base, filter=filter, recursive=recursive) def add_folder(self, path, ignore_existing=True): path, name = self.sanitize(path) diff --git a/src/octoprint/server/api/files.py b/src/octoprint/server/api/files.py index 06cfe363..91cde75a 100644 --- a/src/octoprint/server/api/files.py +++ b/src/octoprint/server/api/files.py @@ -138,8 +138,8 @@ def _getFileList(origin, path=None, filter=None, recursive=False): file_or_folder.update({ "refs": { - "resource": url_for(".readGcodeFile", target=FileDestinations.LOCAL, filename=path + file_or_folder["name"], _external=True), - "download": url_for("index", _external=True) + "downloads/files/" + FileDestinations.LOCAL + "/" + path + file_or_folder["name"] + "resource": url_for(".readGcodeFile", target=FileDestinations.LOCAL, filename=file_or_folder["path"], _external=True), + "download": url_for("index", _external=True) + "downloads/files/" + FileDestinations.LOCAL + "/" + file_or_folder["path"] } })