Skip to content

Commit 9b52d71

Browse files
committed
cleanup(preview): Cleanup the implementation of the new preview backend
Signed-off-by: Carl Schwan <carl.schwan@nextcloud.com>
1 parent 8179214 commit 9b52d71

29 files changed

+370
-688
lines changed

build/psalm-baseline.xml

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2997,17 +2997,6 @@
29972997
<code><![CDATA[$this->timeFactory->getTime()]]></code>
29982998
</InvalidScalarArgument>
29992999
</file>
3000-
<file src="core/Command/Preview/Repair.php">
3001-
<UndefinedInterfaceMethod>
3002-
<code><![CDATA[section]]></code>
3003-
<code><![CDATA[section]]></code>
3004-
</UndefinedInterfaceMethod>
3005-
</file>
3006-
<file src="core/Command/Preview/ResetRenderedTexts.php">
3007-
<InvalidReturnStatement>
3008-
<code><![CDATA[[]]]></code>
3009-
</InvalidReturnStatement>
3010-
</file>
30113000
<file src="core/Command/Security/BruteforceAttempts.php">
30123001
<DeprecatedMethod>
30133002
<code><![CDATA[getAttempts]]></code>

core/BackgroundJobs/MovePreviewJob.php

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
use OCP\DB\Exception;
1818
use OCP\Files\AppData\IAppDataFactory;
1919
use OCP\Files\IAppData;
20-
use OCP\Files\SimpleFS\ISimpleFile;
20+
use OCP\Files\NotFoundException;
2121
use OCP\Files\SimpleFS\ISimpleFolder;
2222
use OCP\IAppConfig;
2323
use OCP\IDBConnection;
@@ -42,15 +42,6 @@ public function __construct(
4242
}
4343

4444
protected function run(mixed $argument): void {
45-
try {
46-
$this->doRun($argument);
47-
} catch (\Throwable $exception) {
48-
echo $exception->getMessage();
49-
throw $exception;
50-
}
51-
}
52-
53-
private function doRun($argument): void {
5445
if ($this->appConfig->getValueBool('core', 'previewMovedDone')) {
5546
return;
5647
}
@@ -118,8 +109,12 @@ private function doRun($argument): void {
118109
}
119110
}
120111

121-
// Delete any leftover preview directory
122-
$this->appData->getFolder('.')->delete();
112+
try {
113+
// Delete any leftover preview directory
114+
$this->appData->getFolder('.')->delete();
115+
} catch (NotFoundException) {
116+
// ignore
117+
}
123118
$this->appConfig->setValueBool('core', 'previewMovedDone', true);
124119
}
125120

@@ -166,7 +161,7 @@ private function processPreviews(array $previewFolders, bool $simplePaths): void
166161
$qb = $this->connection->getQueryBuilder();
167162
$qb->select('*')
168163
->from('filecache')
169-
->where($qb->expr()->like('fileid', $qb->createNamedParameter($fileId)));
164+
->where($qb->expr()->eq('fileid', $qb->createNamedParameter($fileId)));
170165

171166
$result = $qb->executeQuery();
172167
$result = $result->fetchAll();
@@ -175,13 +170,17 @@ private function processPreviews(array $previewFolders, bool $simplePaths): void
175170
foreach ($previewFiles as $previewFile) {
176171
$preview = new Preview();
177172
$preview->setFileId((int)$fileId);
178-
$preview->setOldFileId($previewFile['file']->getId());
173+
/** @var SimpleFile $file */
174+
$file = $previewFile['file'];
175+
$preview->setOldFileId($file->getId());
176+
$preview->setStorageId($result[0]['storage']);
179177
$preview->setEtag($result[0]['etag']);
180178
$preview->setMtime($previewFile['mtime']);
181179
$preview->setWidth($previewFile['width']);
182180
$preview->setHeight($previewFile['height']);
183-
$preview->setCrop($previewFile['crop']);
184-
$preview->setIsMax($previewFile['max']);
181+
$preview->setCropped($previewFile['crop']);
182+
$preview->setMax($previewFile['max']);
183+
$preview->setEncrypted(false);
185184
$preview->setMimetype(match ($previewFile['extension']) {
186185
'png' => IPreview::MIMETYPE_PNG,
187186
'webp' => IPreview::MIMETYPE_WEBP,

core/Command/Preview/Repair.php

Lines changed: 0 additions & 293 deletions
This file was deleted.

0 commit comments

Comments
 (0)