cache on-the-fly

Signed-off-by: Maxence Lange <maxence@artificial-owl.com>
pull/53/head
Maxence Lange 2018-11-27 15:13:37 -01:00
rodzic 1999f06ada
commit a7451538d8
1 zmienionych plików z 5 dodań i 4 usunięć

Wyświetl plik

@ -39,7 +39,6 @@ use OCA\Social\Exceptions\CacheDocumentDoesNotExistException;
use OCA\Social\Model\ActivityPub\ACore;
use OCA\Social\Model\ActivityPub\Document;
use OCA\Social\Service\CacheService;
use OCA\Social\Service\ICoreService;
use OCA\Social\Service\MiscService;
use OCP\Files\NotPermittedException;
use OCP\Files\SimpleFS\ISimpleFile;
@ -77,13 +76,14 @@ class DocumentService implements ICoreService {
/**
* @param string $id
* @param bool $public
*
* @return Document
* @throws CacheDocumentDoesNotExistException
* @throws NotPermittedException
*/
public function cacheRemoteDocument(string $id) {
$document = $this->cacheDocumentsRequest->getById($id);
public function cacheRemoteDocument(string $id, bool $public = false) {
$document = $this->cacheDocumentsRequest->getById($id, $public);
if ($document->getLocalCopy() !== '') {
return $document;
}
@ -117,9 +117,10 @@ class DocumentService implements ICoreService {
* @return ISimpleFile
* @throws CacheContentException
* @throws CacheDocumentDoesNotExistException
* @throws NotPermittedException
*/
public function getFromCache(string $id, bool $public = false) {
$document = $this->cacheDocumentsRequest->getById($id, $public);
$document = $this->cacheRemoteDocument($id, $public);
return $this->cacheService->getContentFromCache($document->getLocalCopy());
}