Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions lib/Command/ClearPreviews.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,18 @@

namespace OCA\Bookmarks\Command;

use OCA\Bookmarks\Db\BookmarkMapper;
use OCA\Bookmarks\Service\FileCache;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;

class ClearPreviews extends Command {
/**
* @var FileCache
*/
private $fileCache;

public function __construct(FileCache $fileCache) {
public function __construct(
private FileCache $fileCache,
private BookmarkMapper $bookmarkMapper,
) {
parent::__construct();
$this->fileCache = $fileCache;
}

/**
Expand All @@ -45,6 +43,7 @@ protected function configure() {
protected function execute(InputInterface $input, OutputInterface $output): int {
try {
$this->fileCache->clear();
$this->bookmarkMapper->clearLastPreviews();
} catch (\Exception $ex) {
$output->writeln('<error>Failed to clear previews</error>');
$output->writeln($ex->getMessage());
Expand Down
12 changes: 12 additions & 0 deletions lib/Db/BookmarkMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -724,12 +724,24 @@ public function findPendingPreviews(int $limit, int $stalePeriod): array {
return $this->findEntities($qb);
}

/**
* @return void
* @throws Exception
*/
public function clearLastPreviews(): void {
$qb = $this->db->getQueryBuilder();
$qb->update('bookmarks');
$qb->set('last_preview', $qb->createNamedParameter(0));
$qb->executeStatement();
}

/**
* @psalm-param Bookmark $entity
* @param Entity $entity
*
* @return Bookmark
* @psalm-return Bookmark
* @throws Exception
*/
public function delete(Entity $entity): Bookmark {
$this->eventDispatcher->dispatch(
Expand Down
Loading