From 8630ec5bebc82c0d5704067ed178c151d725328b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Wed, 15 Feb 2017 16:15:35 +0100 Subject: [PATCH] Fix some bugs in the client lib refactoring * Endless recursion on file delete as reported in #1738 * Broken implementation of .move * Broken definition of .pathForEntry, .entryForPath, .pathForElement and .elementByPath --- src/octoprint/static/js/app/client/files.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/octoprint/static/js/app/client/files.js b/src/octoprint/static/js/app/client/files.js index 3a5cd30e..726949c8 100644 --- a/src/octoprint/static/js/app/client/files.js +++ b/src/octoprint/static/js/app/client/files.js @@ -95,7 +95,7 @@ }; OctoPrintFilesClient.prototype.delete = function (location, path, opts) { - return this.delete(resourceForEntry(location, path), opts); + return this.base.delete(resourceForEntry(location, path), opts); }; OctoPrintFilesClient.prototype.copy = function(location, path, destination, opts) { @@ -103,7 +103,7 @@ }; OctoPrintFilesClient.prototype.move = function(location, path, destination, opts) { - return issueEntryCommand(location, path, "move", { destination: destination }, opts); + return this.issueEntryCommand(location, path, "move", { destination: destination }, opts); }; OctoPrintFilesClient.prototype.createFolder = function (location, name, path, opts) { @@ -129,7 +129,7 @@ return this.base.download(downloadForEntry(location, path), opts); }; - OctoPrintFilesClient.pathForEntry = function(entry) { + OctoPrintFilesClient.prototype.pathForEntry = function(entry) { if (!entry || !entry.hasOwnProperty("parent") || entry.parent == undefined) { return ""; } @@ -145,7 +145,7 @@ return recursivePath(entry.parent, entry.name); }; - OctoPrintFilesClient.entryForPath = function(path, root) { + OctoPrintFilesClient.prototype.entryForPath = function(path, root) { if (_.isArray(root)) { root = {children: root}; } @@ -172,16 +172,16 @@ return recursiveSearch(path.split("/"), root); }; - OctoPrintFilesClient.pathForElement = function(element) { + OctoPrintFilesClient.prototype.pathForElement = function(element) { // TODO Remove in 1.4.x log.warn("pathForElement has been renamed to pathForEntry, please use that instead"); - return OctoPrintFilesClient.pathForEntry(element); + return this.pathForEntry(element); }; - OctoPrintFilesClient.elementByPath = function(location, startElement) { + OctoPrintFilesClient.prototype.elementByPath = function(location, startElement) { // TODO Remove in 1.4.x log.warn("elementByPath has been renamed to entryForPath, please use that instead"); - return OctoPrintFilesClient.entryForPath(location, startElement); + return this.entryForPath(location, startElement); }; OctoPrintClient.registerComponent("files", OctoPrintFilesClient);