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
38 changes: 26 additions & 12 deletions apps/files/lib/Command/ScanAppData.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use OC\DB\ConnectionAdapter;
use OC\Files\Utils\Scanner;
use OC\ForbiddenException;
use OC\Preview\Storage\StorageFactory;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\Files\Folder;
use OCP\Files\IRootFolder;
Expand All @@ -32,10 +33,12 @@ class ScanAppData extends Base {
protected int $foldersCounter = 0;

protected int $filesCounter = 0;
protected int $previewsCounter = -1;

public function __construct(
protected IRootFolder $rootFolder,
protected IConfig $config,
private StorageFactory $previewStorage,
) {
parent::__construct();
}
Expand All @@ -51,6 +54,14 @@ protected function configure(): void {
}

protected function scanFiles(OutputInterface $output, string $folder): int {
if ($folder === 'preview' || $folder === '') {
$this->previewsCounter = $this->previewStorage->scan();

if ($folder === 'preview') {
return self::SUCCESS;
}
}

try {
/** @var Folder $appData */
$appData = $this->getAppDataFolder();
Expand Down Expand Up @@ -134,7 +145,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$this->initTools();

$exitCode = $this->scanFiles($output, $folder);
if ($exitCode === 0) {
if ($exitCode === self::SUCCESS) {
$this->presentStats($output);
}
return $exitCode;
Expand Down Expand Up @@ -162,7 +173,7 @@ protected function initTools(): void {
*
* @throws \ErrorException
*/
public function exceptionErrorHandler($severity, $message, $file, $line) {
public function exceptionErrorHandler(int $severity, string $message, string $file, int $line): void {
if (!(error_reporting() & $severity)) {
// This error code is not included in error_reporting
return;
Expand All @@ -173,10 +184,12 @@ public function exceptionErrorHandler($severity, $message, $file, $line) {
protected function presentStats(OutputInterface $output): void {
// Stop the timer
$this->execTime += microtime(true);

$headers = [
'Folders', 'Files', 'Elapsed time'
];
if ($this->previewsCounter !== -1) {
$headers[] = 'Previews';
}
$headers[] = 'Folders';
$headers[] = 'Files';
$headers[] = 'Elapsed time';

$this->showSummary($headers, null, $output);
}
Expand All @@ -187,14 +200,15 @@ protected function presentStats(OutputInterface $output): void {
* @param string[] $headers
* @param string[] $rows
*/
protected function showSummary($headers, $rows, OutputInterface $output): void {
protected function showSummary(array $headers, ?array $rows, OutputInterface $output): void {
$niceDate = $this->formatExecTime();
if (!$rows) {
$rows = [
$this->foldersCounter,
$this->filesCounter,
$niceDate,
];
if ($this->previewsCounter !== -1) {
$rows[] = $this->previewsCounter;
}
$rows[] = $this->foldersCounter;
$rows[] = $this->filesCounter;
$rows[] = $niceDate;
}
$table = new Table($output);
$table
Expand Down
33 changes: 3 additions & 30 deletions build/psalm-baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1240,9 +1240,11 @@
<code><![CDATA[listen]]></code>
<code><![CDATA[listen]]></code>
</DeprecatedMethod>
<InvalidArgument>
<code><![CDATA[[$this, 'exceptionErrorHandler']]]></code>
</InvalidArgument>
<NullArgument>
<code><![CDATA[null]]></code>
<code><![CDATA[null]]></code>
</NullArgument>
</file>
<file src="apps/files/lib/Controller/DirectEditingController.php">
Expand Down Expand Up @@ -2708,17 +2710,6 @@
<code><![CDATA[$this->timeFactory->getTime()]]></code>
</InvalidScalarArgument>
</file>
<file src="core/Command/Preview/Repair.php">
<UndefinedInterfaceMethod>
<code><![CDATA[section]]></code>
<code><![CDATA[section]]></code>
</UndefinedInterfaceMethod>
</file>
<file src="core/Command/Preview/ResetRenderedTexts.php">
<InvalidReturnStatement>
<code><![CDATA[[]]]></code>
</InvalidReturnStatement>
</file>
<file src="core/Command/Security/BruteforceAttempts.php">
<DeprecatedMethod>
<code><![CDATA[getAttempts]]></code>
Expand Down Expand Up @@ -3721,16 +3712,6 @@
<code><![CDATA[\OCA\Notifications\App]]></code>
</UndefinedClass>
</file>
<file src="lib/private/Preview/BackgroundCleanupJob.php">
<InvalidReturnStatement>
<code><![CDATA[[]]]></code>
</InvalidReturnStatement>
</file>
<file src="lib/private/Preview/Generator.php">
<LessSpecificReturnType>
<code><![CDATA[null|string]]></code>
</LessSpecificReturnType>
</file>
<file src="lib/private/Preview/ProviderV1Adapter.php">
<InvalidReturnStatement>
<code><![CDATA[$thumbnail === false ? null: $thumbnail]]></code>
Expand Down Expand Up @@ -3991,14 +3972,6 @@
<code><![CDATA[array{X-Request-Id: string, Cache-Control: string, Content-Security-Policy: string, Feature-Policy: string, X-Robots-Tag: string, Last-Modified?: string, ETag?: string, ...H}]]></code>
</MoreSpecificReturnType>
</file>
<file src="lib/public/Preview/BeforePreviewFetchedEvent.php">
<LessSpecificReturnStatement>
<code><![CDATA[$this->mode]]></code>
</LessSpecificReturnStatement>
<MoreSpecificReturnType>
<code><![CDATA[null|IPreview::MODE_FILL|IPreview::MODE_COVER]]></code>
</MoreSpecificReturnType>
</file>
<file src="ocs-provider/index.php">
<DeprecatedMethod>
<code><![CDATA[getAppManager]]></code>
Expand Down
9 changes: 9 additions & 0 deletions build/stubs/php-polyfill.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php
/*
* SPDX-FileCopyrightText: None
* SPDX-License-Identifier: CC0-1.0
*/

// PHP 8.4
function array_find(array $array, callable $callback) {}

Loading
Loading