@@ -85,6 +85,7 @@ public function verifyMountPoint(
8585 }
8686
8787 $ newAbsoluteMountPoint = $ this ->generateUniqueTarget (
88+ $ share ,
8889 Filesystem::normalizePath ($ absoluteParent . '/ ' . $ mountPoint ),
8990 $ parentMount ,
9091 $ allCachedMounts ,
@@ -107,7 +108,12 @@ public function verifyMountPoint(
107108 /**
108109 * @param ICachedMountInfo[] $allCachedMounts
109110 */
110- private function generateUniqueTarget (string $ absolutePath , IMountPoint $ parentMount , array $ allCachedMounts ): string {
111+ private function generateUniqueTarget (
112+ IShare $ share ,
113+ string $ absolutePath ,
114+ IMountPoint $ parentMount ,
115+ array $ allCachedMounts ,
116+ ): string {
111117 $ pathInfo = pathinfo ($ absolutePath );
112118 $ ext = isset ($ pathInfo ['extension ' ]) ? '. ' . $ pathInfo ['extension ' ] : '' ;
113119 $ name = $ pathInfo ['filename ' ];
@@ -116,7 +122,7 @@ private function generateUniqueTarget(string $absolutePath, IMountPoint $parentM
116122 $ i = 2 ;
117123 $ parentCache = $ parentMount ->getStorage ()->getCache ();
118124 $ internalPath = $ parentMount ->getInternalPath ($ absolutePath );
119- while ($ parentCache ->inCache ($ internalPath ) || isset ( $ allCachedMounts[ $ absolutePath . ' / ' ] )) {
125+ while ($ parentCache ->inCache ($ internalPath ) || $ this -> hasConflictingMount ( $ share , $ allCachedMounts, $ absolutePath )) {
120126 $ absolutePath = Filesystem::normalizePath ($ dir . '/ ' . $ name . ' ( ' . $ i . ') ' . $ ext );
121127 $ internalPath = $ parentMount ->getInternalPath ($ absolutePath );
122128 $ i ++;
@@ -125,6 +131,23 @@ private function generateUniqueTarget(string $absolutePath, IMountPoint $parentM
125131 return $ absolutePath ;
126132 }
127133
134+ /**
135+ * @param ICachedMountInfo[] $allCachedMounts
136+ */
137+ private function hasConflictingMount (IShare $ share , array $ allCachedMounts , string $ absolutePath ): bool {
138+ if (!isset ($ allCachedMounts [$ absolutePath . '/ ' ])) {
139+ return false ;
140+ }
141+
142+ $ mount = $ allCachedMounts [$ absolutePath . '/ ' ];
143+ if ($ mount ->getMountProvider () === MountProvider::class && $ mount ->getRootId () === $ share ->getNodeId ()) {
144+ // "conflicting" mount is a mount for the current share
145+ return false ;
146+ }
147+
148+ return true ;
149+ }
150+
128151 /**
129152 * update fileTarget in the database if the mount point changed
130153 *
0 commit comments