Skip to content

Commit

Permalink
support files_external
Browse files Browse the repository at this point in the history
Signed-off-by: Maxence Lange <maxence@artificial-owl.com>
  • Loading branch information
ArtificialOwl committed Aug 21, 2023
1 parent dad1155 commit 226bec9
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
19 changes: 13 additions & 6 deletions lib/Model/FileCacheWrapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@

namespace OCA\Circles\Model;

use JsonSerializable;
use OCA\Circles\Db\CoreQueryBuilder;
use OCA\Circles\Exceptions\FileCacheNotFoundException;
use OCA\Circles\Tools\Db\IQueryRow;
use OCA\Circles\Tools\Exceptions\InvalidItemException;
use OCA\Circles\Tools\IDeserializable;
use OCA\Circles\Tools\Traits\TArrayTools;
use JsonSerializable;
use OCA\Circles\Db\CoreQueryBuilder;
use OCA\Circles\Exceptions\FileCacheNotFoundException;

/**
* Class FileCacheWrapper
Expand Down Expand Up @@ -451,12 +451,19 @@ public function toCache(): array {
* @return bool
*/
public function isAccessible(): bool {
if ($this->getId() === 0 || $this->getPath() === '') {
if ($this->getId() === 0) {
return false;
}

return !(explode('/', $this->getPath(), 2)[0] !== 'files'
&& explode(':', $this->getStorage(), 2)[0] === 'home');
$path = $this->getPath();
[$storageType,] = explode('::', $this->getStorage(), 2);

if ($path === '') {
// we only accept empty path on external storage
return (in_array($storageType, ['local', 'webdav', 'ftp', 'sftp', 'swift', 'smb', 'amazon']));
}

return !(explode('/', $path, 2)[0] !== 'files' && $storageType === 'home');
}


Expand Down
5 changes: 5 additions & 0 deletions lib/ShareByCircleProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,11 @@ public function getSharesInFolder($userId, Folder $node, $reshares, $shallow = t
if ($wrappedShare->getFileCache()->isAccessible()) {
$result[$wrappedShare->getFileSource()][] =
$wrappedShare->getShare($this->rootFolder, $this->userManager, $this->urlGenerator);
} else {
$this->logger->debug('shared document is not available anymore', ['wrappedShare' => $wrappedShare]);
if ($wrappedShare->getFileCache()->getPath() === '') {
$this->logger->notice('share is not available while path is empty. might comes from an unsupported storage.', ['wrappedShare' => $wrappedShare]);
}
}
}

Expand Down

0 comments on commit 226bec9

Please sign in to comment.