From ccfa4e204e6974ef073ed3a12e97176c6c38807b Mon Sep 17 00:00:00 2001 From: Jan <33495614+Jojo-1000@users.noreply.github.com> Date: Sun, 10 Dec 2023 00:25:47 +0100 Subject: [PATCH] Fix restore search error in RestoreController (#4998) * Fix restore search error in RestoreController. TypeError: Cannot read Property 'Path' of undefined. Add a break to for loop, thanks @tx0h (#4997). * Remove empty '\' entries from restore picker. The paths are split by dirsep, but directories end with it, which results in an empty part at the end. --- .../webroot/ngax/scripts/controllers/RestoreController.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Duplicati/Server/webroot/ngax/scripts/controllers/RestoreController.js b/Duplicati/Server/webroot/ngax/scripts/controllers/RestoreController.js index 14ddedcf8..4ebec1005 100644 --- a/Duplicati/Server/webroot/ngax/scripts/controllers/RestoreController.js +++ b/Duplicati/Server/webroot/ngax/scripts/controllers/RestoreController.js @@ -246,6 +246,10 @@ backupApp.controller('RestoreController', function ($rootScope, $scope, $routePa if (cp.indexOf(compareablePath(sn.Path)) == 0) { var curpath = sn.Path; var parts = p.substr(sn.Path.length).split(dirsep); + // Remove empty part if path had dirsep at end + if (parts[parts.length - 1].length == 0) { + parts.pop(); + } var col = sn; for(var k in parts) { @@ -261,6 +265,7 @@ backupApp.controller('RestoreController', function ($rootScope, $scope, $routePa if (compareablePath(col.Children[m].Path) == compareablePath(curpath)) { found = true; col = col.Children[m]; + break; } }