From 5151b2267ae053b50934ee52c16450421128133f Mon Sep 17 00:00:00 2001 From: Florian Gnaegi - frentix GmbH <gnaegi@frentix.com> Date: Wed, 19 Mar 2014 12:40:28 +0100 Subject: [PATCH] OO-1027 fix race condition in folder component with file selection --- .../modules/bc/FolderRunController.java | 21 ++++++++++++------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/src/main/java/org/olat/core/commons/modules/bc/FolderRunController.java b/src/main/java/org/olat/core/commons/modules/bc/FolderRunController.java index 48e542a5c3b..12b8f9c78d0 100644 --- a/src/main/java/org/olat/core/commons/modules/bc/FolderRunController.java +++ b/src/main/java/org/olat/core/commons/modules/bc/FolderRunController.java @@ -438,17 +438,22 @@ public class FolderRunController extends BasicController implements Activateable private void enableDisableQuota(UserRequest ureq) { //prevent a timing condition if the user logout while a thumbnail is generated if (ureq.getUserSession() == null || ureq.getUserSession().getRoles() == null) { - folderContainer.contextPut("editQuota", Boolean.FALSE); return; - } else if (!ureq.getUserSession().getRoles().isOLATAdmin()) { - if (!ureq.getUserSession().getRoles().isInstitutionalResourceManager()) { - folderContainer.contextPut("editQuota", Boolean.FALSE); - return; - } + } + + Boolean newEditQuota = Boolean.FALSE; + if (ureq.getUserSession().getRoles().isOLATAdmin() || ureq.getUserSession().getRoles().isInstitutionalResourceManager()) { + // Only sys admins or institutonal resource managers can have the quota button + Quota q = VFSManager.isTopLevelQuotaContainer(folderComponent.getCurrentContainer()); + newEditQuota = (q == null)? Boolean.FALSE : Boolean.TRUE; } - Quota q = VFSManager.isTopLevelQuotaContainer(folderComponent.getCurrentContainer()); - folderContainer.contextPut("editQuota", (q == null)? Boolean.FALSE : Boolean.TRUE); + Boolean currentEditQuota = (Boolean) folderContainer.contextGet("editQuota"); + // Update the container only if a new value is available or no value is set to + // not make the component dirty after asynchronous thumbnail loading + if (currentEditQuota == null || !currentEditQuota.equals(newEditQuota)) { + folderContainer.contextPut("editQuota", newEditQuota); + } } /** -- GitLab