From 26ef1e5769ae504677a9824ac7d7dd6c4fa39263 Mon Sep 17 00:00:00 2001 From: yflory Date: Fri, 7 Jun 2019 11:05:15 +0200 Subject: [PATCH] Fix infinite loop when trying to display an invalid category in the drive --- www/drive/inner.js | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/www/drive/inner.js b/www/drive/inner.js index b6c2a51c4..7302f9bd1 100644 --- a/www/drive/inner.js +++ b/www/drive/inner.js @@ -2697,25 +2697,29 @@ define([ // NOTE: Elements in the trash are not using the same storage structure as the others var _displayDirectory = function (path, force) { APP.hideMenu(); + if (!APP.editable) { debug("Read-only mode"); } if (!appStatus.isReady && !force) { return; } - // Only Trash and Root are available in not-owned files manager - if (!path || displayedCategories.indexOf(path[0]) === -1) { - log(Messages.fm_categoryError); - currentPath = [ROOT]; - _displayDirectory(currentPath); - return; + if (!path || path.length === 0) { + // Only Trash and Root are available in not-owned files manager + if (!path || displayedCategories.indexOf(path[0]) === -1) { + log(Messages.fm_categoryError); + } + if (!APP.loggedIn && APP.newSharedFolder) { + // ANON_SHARED_FOLDER + path = [SHARED_FOLDER, ROOT]; + } else { + path = [ROOT]; + } } + appStatus.ready(false); currentPath = path; var s = $content.scrollTop() || 0; $content.html(""); sel.$selectBox = $('
', {'class': 'cp-app-drive-content-select-box'}) .appendTo($content); - if (!path || path.length === 0) { - path = [ROOT]; - } var isInRoot = manager.isPathIn(path, [ROOT]); var inTrash = manager.isPathIn(path, [TRASH]); var isTrashRoot = manager.comparePath(path, [TRASH]); @@ -2726,6 +2730,10 @@ define([ var isTags = path[0] === TAGS; // ANON_SHARED_FOLDER var isSharedFolder = path[0] === SHARED_FOLDER && APP.newSharedFolder; + if (isSharedFolder && path.length < 2) { + path = [SHARED_FOLDER, 'root']; + currentPath = path; + } var root = isVirtual ? undefined : manager.find(path); if (manager.isSharedFolder(root)) {