Skip to content

Commit c202eb4

Browse files
authored
Merge pull request #1386 from nextcloud/backport/1369/1369-stable27
[stable27] support files_external
2 parents 56db81d + aef3943 commit c202eb4

File tree

2 files changed

+18
-6
lines changed

2 files changed

+18
-6
lines changed

lib/Model/FileCacheWrapper.php

+13-6
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,13 @@
3131

3232
namespace OCA\Circles\Model;
3333

34+
use JsonSerializable;
35+
use OCA\Circles\Db\CoreQueryBuilder;
36+
use OCA\Circles\Exceptions\FileCacheNotFoundException;
3437
use OCA\Circles\Tools\Db\IQueryRow;
3538
use OCA\Circles\Tools\Exceptions\InvalidItemException;
3639
use OCA\Circles\Tools\IDeserializable;
3740
use OCA\Circles\Tools\Traits\TArrayTools;
38-
use JsonSerializable;
39-
use OCA\Circles\Db\CoreQueryBuilder;
40-
use OCA\Circles\Exceptions\FileCacheNotFoundException;
4141

4242
/**
4343
* Class FileCacheWrapper
@@ -451,12 +451,19 @@ public function toCache(): array {
451451
* @return bool
452452
*/
453453
public function isAccessible(): bool {
454-
if ($this->getId() === 0 || $this->getPath() === '') {
454+
if ($this->getId() === 0) {
455455
return false;
456456
}
457457

458-
return !(explode('/', $this->getPath(), 2)[0] !== 'files'
459-
&& explode(':', $this->getStorage(), 2)[0] === 'home');
458+
$path = $this->getPath();
459+
[$storageType,] = explode('::', $this->getStorage(), 2);
460+
461+
if ($path === '') {
462+
// we only accept empty path on external storage
463+
return (in_array($storageType, ['local', 'webdav', 'ftp', 'sftp', 'swift', 'smb', 'amazon']));
464+
}
465+
466+
return !(explode('/', $path, 2)[0] !== 'files' && $storageType === 'home');
460467
}
461468

462469

lib/ShareByCircleProvider.php

+5
Original file line numberDiff line numberDiff line change
@@ -401,6 +401,11 @@ public function getSharesInFolder($userId, Folder $node, $reshares, $shallow = t
401401
if ($wrappedShare->getFileCache()->isAccessible()) {
402402
$result[$wrappedShare->getFileSource()][] =
403403
$wrappedShare->getShare($this->rootFolder, $this->userManager, $this->urlGenerator);
404+
} else {
405+
$this->logger->debug('shared document is not available anymore', ['wrappedShare' => $wrappedShare]);
406+
if ($wrappedShare->getFileCache()->getPath() === '') {
407+
$this->logger->notice('share is not available while path is empty. might comes from an unsupported storage.', ['wrappedShare' => $wrappedShare]);
408+
}
404409
}
405410
}
406411

0 commit comments

Comments
 (0)