|
13 | 13 | use OCA\DAV\CalDAV\DefaultCalendarValidator; |
14 | 14 | use OCA\DAV\Connector\Sabre\Directory; |
15 | 15 | use OCA\DAV\Connector\Sabre\FilesPlugin; |
| 16 | +use OCA\Files_Trashbin\Sabre\TrashRoot; |
16 | 17 | use OCP\DB\QueryBuilder\IQueryBuilder; |
| 18 | +use OCP\Files\Folder; |
17 | 19 | use OCP\IDBConnection; |
18 | 20 | use OCP\IUser; |
19 | 21 | use Sabre\DAV\Exception as DavException; |
@@ -220,10 +222,16 @@ public function propFind($path, PropFind $propFind) { |
220 | 222 | } |
221 | 223 |
|
222 | 224 | $node = $this->tree->getNodeForPath($path); |
223 | | - if ($node instanceof Directory && $propFind->getDepth() !== 0) { |
224 | | - $this->cacheDirectory($path, $node); |
| 225 | + if (($node instanceof Directory) && $propFind->getDepth() !== 0) { |
| 226 | + $this->cacheDirectory($path, $node->getNode()); |
| 227 | + } else if ($node instanceof TrashRoot) { |
| 228 | + $trashNodes = $node->getTrashRoots(); |
| 229 | + foreach ($trashNodes as $trashNode) { |
| 230 | + $this->cacheDirectory($path, $trashNode); |
| 231 | + } |
225 | 232 | } |
226 | 233 |
|
| 234 | + |
227 | 235 | // First fetch the published properties (set by another user), then get the ones set by |
228 | 236 | // the current user. If both are set then the latter as priority. |
229 | 237 | foreach ($this->getPublishedProperties($path, $requestedProps) as $propName => $propValue) { |
@@ -344,18 +352,17 @@ private function getPublishedProperties(string $path, array $requestedProperties |
344 | 352 | /** |
345 | 353 | * prefetch all user properties in a directory |
346 | 354 | */ |
347 | | - private function cacheDirectory(string $path, Directory $node): void { |
| 355 | + private function cacheDirectory(string $path, Folder $node): void { |
348 | 356 | $prefix = ltrim($path . '/', '/'); |
349 | 357 | $query = $this->connection->getQueryBuilder(); |
350 | 358 | $query->select('name', 'p.propertypath', 'p.propertyname', 'p.propertyvalue', 'p.valuetype') |
351 | 359 | ->from('filecache', 'f') |
352 | | - ->hintShardKey('storage', $node->getNode()->getMountPoint()->getNumericStorageId()) |
| 360 | + ->hintShardKey('storage', $node->getMountPoint()->getNumericStorageId()) |
353 | 361 | ->leftJoin('f', 'properties', 'p', $query->expr()->eq('p.propertypath', $query->func()->concat( |
354 | 362 | $query->createNamedParameter($prefix), |
355 | 363 | 'f.name' |
356 | | - )), |
357 | | - ) |
358 | | - ->where($query->expr()->eq('parent', $query->createNamedParameter($node->getInternalFileId(), IQueryBuilder::PARAM_INT))) |
| 364 | + ))) |
| 365 | + ->where($query->expr()->eq('parent', $query->createNamedParameter($node->getId(), IQueryBuilder::PARAM_INT))) |
359 | 366 | ->andWhere($query->expr()->orX( |
360 | 367 | $query->expr()->eq('p.userid', $query->createNamedParameter($this->user->getUID())), |
361 | 368 | $query->expr()->isNull('p.userid'), |
|
0 commit comments