1212use OC \Files \FileInfo ;
1313use OC \Files \Node \Folder ;
1414use OC \Files \View ;
15+ use OCA \GroupFolders \Mount \GroupMountPoint ;
1516use OCA \WorkflowEngine \Entity \File ;
1617use OCP \EventDispatcher \Event ;
1718use OCP \Files \Cache \ICacheEntry ;
@@ -62,7 +63,7 @@ public function checkFileAccess(string $path, IMountPoint $mountPoint, bool $isD
6263
6364 $ this ->nestingLevel ++;
6465
65- $ filePath = $ this ->translatePath ($ storage , $ path );
66+ $ filePath = $ this ->translatePath ($ mountPoint , $ storage , $ path );
6667 $ ruleMatcher = $ this ->manager ->getRuleMatcher ();
6768 $ ruleMatcher ->setFileInfo ($ storage , $ filePath , $ isDir );
6869 $ node = $ this ->getNode ($ path , $ mountPoint , $ cacheEntry );
@@ -119,8 +120,31 @@ protected function isBlockablePath(IMountPoint $mountPoint, string $path): bool
119120 /**
120121 * For thumbnails and versions we want to check the tags of the original file
121122 */
122- protected function translatePath (IStorage $ storage , string $ path ): string {
123- if (substr_count ($ path , '/ ' ) < 1 ) {
123+ protected function translatePath (IMountPoint $ mountPoint , IStorage $ storage , string $ path ): string {
124+ if ($ mountPoint instanceof GroupMountPoint) {
125+ /**
126+ * Case | Mount point path | Path ($path)
127+ * --------+---------------------------------------+--------------------------------
128+ * Files | /user/files/$folderName/ | Subfolder/File.txt
129+ * Trash | /user/files_trashbin/groupfolder/$id/ | Subfolder/File.txt.v{timestamp}
130+ * Version | /user/files_versions/groupfolder/$id/ | Subfolder/File.txt.d{timestamp}
131+ */
132+ $ mountPath = $ mountPoint ->getMountPoint ();
133+ if (substr_count ($ mountPath , '/ ' ) >= 3 ) {
134+ [,, $ folder ] = explode ('/ ' , $ mountPath );
135+ if ($ folder === 'files_versions ' && preg_match ('/.+\.v\d{10}$/ ' , basename ($ path ))) {
136+ // Remove trailing ".v{timestamp}"
137+ return substr ($ path , 0 , -12 );
138+ }
139+ if ($ folder === 'files_trashbin ' && preg_match ('/.+\.d\d{10}$/ ' , basename ($ path ))) {
140+ // Remove trailing ".d{timestamp}"
141+ return substr ($ path , 0 , -12 );
142+ }
143+ }
144+ return $ path ;
145+ }
146+
147+ if (substr_count ($ path , '/ ' ) === 0 ) {
124148 return $ path ;
125149 }
126150
@@ -138,7 +162,7 @@ protected function translatePath(IStorage $storage, string $path): string {
138162 // 'versions', 'path/to/file.txt'
139163 $ segments = explode ('/ ' , $ innerPath , 2 );
140164 if (isset ($ segments [1 ])) {
141- $ innerPath = $ segments[ 1 ] ;
165+ [ $ folder , $ innerPath] = $ segments ;
142166 }
143167
144168 if (preg_match ('/.+\.d\d{10}$/ ' , basename ($ innerPath ))) {
@@ -176,6 +200,10 @@ protected function isCreatingSkeletonFiles(): bool {
176200 && isset ($ step ['function ' ]) && $ step ['function ' ] === 'tryLogin ' ) {
177201 return true ;
178202 }
203+ if (isset ($ step ['class ' ]) && $ step ['class ' ] === \OCA \GroupFolders \Trash \TrashBackend::class
204+ && isset ($ step ['function ' ]) && $ step ['function ' ] === 'setupTrashFolder ' ) {
205+ return true ;
206+ }
179207 }
180208
181209 return false ;
0 commit comments