Add preview generator check to write
parent
69184e0bb0
commit
506ea05d8b
|
@ -24,6 +24,7 @@ declare(strict_types=1);
|
|||
namespace OCA\Memories\Command;
|
||||
|
||||
use OCA\Files_External\Service\GlobalStoragesService;
|
||||
use OCA\Memories\AppInfo\Application;
|
||||
use OCA\Memories\Db\TimelineWrite;
|
||||
use OCP\Encryption\IManager;
|
||||
use OCP\Files\File;
|
||||
|
@ -52,7 +53,7 @@ class Index extends Command
|
|||
|
||||
protected IUserManager $userManager;
|
||||
protected IRootFolder $rootFolder;
|
||||
protected IPreview $previewGenerator;
|
||||
protected IPreview $preview;
|
||||
protected IConfig $config;
|
||||
protected OutputInterface $output;
|
||||
protected IManager $encryptionManager;
|
||||
|
@ -67,7 +68,7 @@ class Index extends Command
|
|||
public function __construct(
|
||||
IRootFolder $rootFolder,
|
||||
IUserManager $userManager,
|
||||
IPreview $previewGenerator,
|
||||
IPreview $preview,
|
||||
IConfig $config,
|
||||
IManager $encryptionManager,
|
||||
IDBConnection $connection,
|
||||
|
@ -77,11 +78,11 @@ class Index extends Command
|
|||
|
||||
$this->userManager = $userManager;
|
||||
$this->rootFolder = $rootFolder;
|
||||
$this->previewGenerator = $previewGenerator;
|
||||
$this->preview = $preview;
|
||||
$this->config = $config;
|
||||
$this->encryptionManager = $encryptionManager;
|
||||
$this->connection = $connection;
|
||||
$this->timelineWrite = new TimelineWrite($this->connection);
|
||||
$this->timelineWrite = new TimelineWrite($connection, $preview);
|
||||
|
||||
try {
|
||||
$this->globalService = $container->get(GlobalStoragesService::class);
|
||||
|
@ -112,6 +113,16 @@ class Index extends Command
|
|||
|
||||
protected function execute(InputInterface $input, OutputInterface $output): int
|
||||
{
|
||||
// Print mime type support information
|
||||
$output->writeln('MIME Type support:');
|
||||
foreach (Application::IMAGE_MIMES as $mimeType) {
|
||||
if ($this->preview->isMimeSupported($mimeType)) {
|
||||
$output->writeln(" {$mimeType}: supported");
|
||||
} else {
|
||||
$output->writeln(" {$mimeType}: <error>not supported by preview generator</error>");
|
||||
}
|
||||
}
|
||||
|
||||
// Get options and arguments
|
||||
$refresh = $input->getOption('refresh') ? true : false;
|
||||
$clear = $input->getOption('clear') ? true : false;
|
||||
|
|
|
@ -53,7 +53,7 @@ class ApiController extends Controller
|
|||
private IAppManager $appManager;
|
||||
private TimelineQuery $timelineQuery;
|
||||
private TimelineWrite $timelineWrite;
|
||||
private IPreview $previewManager;
|
||||
private IPreview $preview;
|
||||
|
||||
public function __construct(
|
||||
IRequest $request,
|
||||
|
@ -62,7 +62,7 @@ class ApiController extends Controller
|
|||
IDBConnection $connection,
|
||||
IRootFolder $rootFolder,
|
||||
IAppManager $appManager,
|
||||
IPreview $previewManager
|
||||
IPreview $preview
|
||||
) {
|
||||
parent::__construct(Application::APPNAME, $request);
|
||||
|
||||
|
@ -71,9 +71,9 @@ class ApiController extends Controller
|
|||
$this->connection = $connection;
|
||||
$this->rootFolder = $rootFolder;
|
||||
$this->appManager = $appManager;
|
||||
$this->previewManager = $previewManager;
|
||||
$this->previewManager = $preview;
|
||||
$this->timelineQuery = new TimelineQuery($this->connection);
|
||||
$this->timelineWrite = new TimelineWrite($connection);
|
||||
$this->timelineWrite = new TimelineWrite($connection, $preview);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -9,14 +9,17 @@ use OCA\Memories\Exif;
|
|||
use OCP\DB\QueryBuilder\IQueryBuilder;
|
||||
use OCP\Files\File;
|
||||
use OCP\IDBConnection;
|
||||
use OCP\IPreview;
|
||||
|
||||
class TimelineWrite
|
||||
{
|
||||
protected IDBConnection $connection;
|
||||
protected IPreview $preview;
|
||||
|
||||
public function __construct(IDBConnection $connection)
|
||||
public function __construct(IDBConnection $connection, IPreview &$preview)
|
||||
{
|
||||
$this->connection = $connection;
|
||||
$this->preview = $preview;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -58,6 +61,11 @@ class TimelineWrite
|
|||
return 0;
|
||||
}
|
||||
|
||||
// Make sure preview generator supports the mime type
|
||||
if (!$this->preview->isMimeSupported($file->getMimeType())) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Get parameters
|
||||
$mtime = $file->getMtime();
|
||||
$fileId = $file->getId();
|
||||
|
|
|
@ -27,14 +27,15 @@ use OCP\EventDispatcher\IEventListener;
|
|||
use OCP\Files\Events\Node\NodeDeletedEvent;
|
||||
use OCP\Files\Folder;
|
||||
use OCP\IDBConnection;
|
||||
use OCP\IPreview;
|
||||
|
||||
class PostDeleteListener implements IEventListener
|
||||
{
|
||||
private TimelineWrite $util;
|
||||
|
||||
public function __construct(IDBConnection $connection)
|
||||
public function __construct(IDBConnection $connection, IPreview $preview)
|
||||
{
|
||||
$this->util = new TimelineWrite($connection);
|
||||
$this->util = new TimelineWrite($connection, $preview);
|
||||
}
|
||||
|
||||
public function handle(Event $event): void
|
||||
|
|
|
@ -28,6 +28,7 @@ use OCP\Files\Events\Node\NodeTouchedEvent;
|
|||
use OCP\Files\Events\Node\NodeWrittenEvent;
|
||||
use OCP\Files\Folder;
|
||||
use OCP\IDBConnection;
|
||||
use OCP\IPreview;
|
||||
use OCP\IUserManager;
|
||||
|
||||
class PostWriteListener implements IEventListener
|
||||
|
@ -36,10 +37,11 @@ class PostWriteListener implements IEventListener
|
|||
|
||||
public function __construct(
|
||||
IDBConnection $connection,
|
||||
IUserManager $userManager
|
||||
IUserManager $userManager,
|
||||
IPreview $preview
|
||||
) {
|
||||
$this->userManager = $userManager;
|
||||
$this->timelineWrite = new TimelineWrite($connection);
|
||||
$this->timelineWrite = new TimelineWrite($connection, $preview);
|
||||
}
|
||||
|
||||
public function handle(Event $event): void
|
||||
|
|
Loading…
Reference in New Issue