Files
nextcloud-ng_backup/lib/Migration/Version000002Date20261002010000.php
dillard 807353cbe4 Wire Psalm into CI, fix a real bug it found in user-migration import
RepositoryImportSource::copyToFolder() called putContent() on the generic
return type of Node::get(), which doesn't declare that method -- only
File does. Existing-file overwrite during a per-user restore would have
fatally errored at runtime; added an instanceof check and a resource leak
fix (finally-close) while there. Also guarded getFileAsStream() against
fopen() returning false.

Everything else Psalm (strict level) currently flags is mechanical
(missing `final` on leaf classes -- applied everywhere safe) or pre-existing
array-shape/type gaps, captured in psalm-baseline.xml so CI fails only on
new issues from here on, not the whole backlog at once.
2026-10-05 11:45:37 +02:00

34 lines
1.2 KiB
PHP

<?php
declare(strict_types=1);
// SPDX-FileCopyrightText: 2026 Dillard Blom
// SPDX-License-Identifier: AGPL-3.0-or-later
namespace OCA\NgBackup\Migration;
use Closure;
use OCP\DB\ISchemaWrapper;
use OCP\DB\Types;
use OCP\Migration\IOutput;
use OCP\Migration\SimpleMigrationStep;
/** Local cache of the per-pack index files, so opening a repository does not download them all. */
final class Version000002Date20261002010000 extends SimpleMigrationStep {
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper {
/** @var ISchemaWrapper $schema */
$schema = $schemaClosure();
if (!$schema->hasTable('ngb_index')) {
$t = $schema->createTable('ngb_index');
$t->addColumn('id', Types::BIGINT, ['autoincrement' => true, 'notnull' => true, 'unsigned' => true]);
$t->addColumn('repository_id', Types::STRING, ['notnull' => true, 'length' => 32]);
$t->addColumn('pack_id', Types::STRING, ['notnull' => true, 'length' => 32]);
// Plain JSON list of blob entries. Blob ids are keyed hashes and reveal no content.
$t->addColumn('entries', Types::TEXT, ['notnull' => true]);
$t->setPrimaryKey(['id']);
$t->addUniqueIndex(['repository_id', 'pack_id'], 'ngb_index_repo_pack');
}
return $schema;
}
}