From e3b5957efcecc446864199128a2e0eeacca94c61 Mon Sep 17 00:00:00 2001
From: srosse <stephane.rosse@frentix.com>
Date: Tue, 1 Oct 2019 11:05:38 +0200
Subject: [PATCH] OO-4286: deduplicate owned or coached shared folders in
 WebDAV provider

---
 .../sharedfolder/SharedFolderWebDAVMergeSource.java  | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/src/main/java/org/olat/modules/sharedfolder/SharedFolderWebDAVMergeSource.java b/src/main/java/org/olat/modules/sharedfolder/SharedFolderWebDAVMergeSource.java
index e0b32172d7d..824f6ccc47d 100644
--- a/src/main/java/org/olat/modules/sharedfolder/SharedFolderWebDAVMergeSource.java
+++ b/src/main/java/org/olat/modules/sharedfolder/SharedFolderWebDAVMergeSource.java
@@ -64,10 +64,12 @@ public class SharedFolderWebDAVMergeSource extends WebDAVMergeSource {
 		
 		List<RepositoryEntry> ownerEntries = repoManager.queryByMembership(getIdentity(), true, true, false, SharedFolderFileResource.TYPE_NAME);
 		for (RepositoryEntry entry : ownerEntries) {
-			VFSContainer container = sfm.getNamedSharedFolder(entry, true);
-			if(container != null) {
-				addContainerToList(container, containers);
-				addedEntries.add(entry.getKey());
+			if(entry != null && !addedEntries.contains(entry.getKey())) {
+				VFSContainer container = sfm.getNamedSharedFolder(entry, true);
+				if(container != null) {
+					addContainerToList(container, containers);
+					addedEntries.add(entry.getKey());
+				}
 			}
 		}
 		
@@ -77,7 +79,7 @@ public class SharedFolderWebDAVMergeSource extends WebDAVMergeSource {
 		}
 
 		// see /webapp/WEB-INF/classes/org/olat/core/commons/services/webdav/webdavContext.xml
-		if (publiclyReadableFolders != null && publiclyReadableFolders.size() > 0) {
+		if (publiclyReadableFolders != null && !publiclyReadableFolders.isEmpty()) {
 			// Temporarily save added entries. This is needed to make sure not to add an entry twice.
 			
 			String firstItem = publiclyReadableFolders.get(0);
-- 
GitLab