|
12 | 12 | use OC\Files\FileInfo; |
13 | 13 | use OC\Files\Node\Folder; |
14 | 14 | use OC\Files\View; |
| 15 | +use OCA\GroupFolders\Mount\GroupMountPoint; |
15 | 16 | use OCA\WorkflowEngine\Entity\File; |
16 | 17 | use OCP\EventDispatcher\Event; |
17 | 18 | use OCP\Files\Cache\ICacheEntry; |
@@ -62,7 +63,7 @@ public function checkFileAccess(string $path, IMountPoint $mountPoint, bool $isD |
62 | 63 |
|
63 | 64 | $this->nestingLevel++; |
64 | 65 |
|
65 | | - $filePath = $this->translatePath($storage, $path); |
| 66 | + $filePath = $this->translatePath($mountPoint, $storage, $path); |
66 | 67 | $ruleMatcher = $this->manager->getRuleMatcher(); |
67 | 68 | $ruleMatcher->setFileInfo($storage, $filePath, $isDir); |
68 | 69 | $node = $this->getNode($path, $mountPoint, $cacheEntry); |
@@ -119,8 +120,31 @@ protected function isBlockablePath(IMountPoint $mountPoint, string $path): bool |
119 | 120 | /** |
120 | 121 | * For thumbnails and versions we want to check the tags of the original file |
121 | 122 | */ |
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) { |
124 | 148 | return $path; |
125 | 149 | } |
126 | 150 |
|
@@ -176,6 +200,10 @@ protected function isCreatingSkeletonFiles(): bool { |
176 | 200 | && isset($step['function']) && $step['function'] === 'tryLogin') { |
177 | 201 | return true; |
178 | 202 | } |
| 203 | + if (isset($step['class']) && $step['class'] === \OCA\GroupFolders\Trash\TrashBackend::class |
| 204 | + && isset($step['function']) && $step['function'] === 'setupTrashFolder') { |
| 205 | + return true; |
| 206 | + } |
179 | 207 | } |
180 | 208 |
|
181 | 209 | return false; |
|
0 commit comments