Skip to content

Commit

Permalink
+files_metadata_installed
Browse files Browse the repository at this point in the history
Signed-off-by: Maxence Lange <maxence@artificial-owl.com>
  • Loading branch information
ArtificialOwl committed Dec 4, 2023
1 parent 1fd6273 commit b02833e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
7 changes: 7 additions & 0 deletions core/Migrations/Version28000Date20231004103301.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,16 @@
use Closure;
use OCP\DB\ISchemaWrapper;
use OCP\DB\Types;
use OCP\IConfig;
use OCP\Migration\IOutput;
use OCP\Migration\SimpleMigrationStep;

// Create new tables for the Metadata API (files_metadata and files_metadata_index).
class Version28000Date20231004103301 extends SimpleMigrationStep {

public function __construct(private IConfig $config) {
}

public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper {
/** @var ISchemaWrapper $schema */
$schema = $schemaClosure();
Expand Down Expand Up @@ -94,6 +99,8 @@ public function changeSchema(IOutput $output, Closure $schemaClosure, array $opt
return null;
}

$this->config->setAppValue('core', 'files_metadata_installed', '1');

return $schema;
}
}
5 changes: 3 additions & 2 deletions lib/private/FilesMetadata/FilesMetadataManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
*/
class FilesMetadataManager implements IFilesMetadataManager {
public const CONFIG_KEY = 'files_metadata';
public const MIGRATION_DONE = 'files_metadata_installed';
private const JSON_MAXSIZE = 100000;

private ?IFilesMetadata $all = null;
Expand Down Expand Up @@ -241,8 +242,8 @@ public function getMetadataQuery(
string $fileTableAlias,
string $fileIdField
): ?IMetadataQuery {
// we don't want to join metadata table if never filled
if ($this->config->getAppValue('core', self::CONFIG_KEY, '') === '') {
// we don't want to join metadata table if table does not exist - condition can be removed post 29.
if ($this->config->getAppValue('core', self::MIGRATION_DONE, '0') !== '1') {
return null;
}
return new MetadataQuery($qb, $this->getKnownMetadata(), $fileTableAlias, $fileIdField);
Expand Down

0 comments on commit b02833e

Please sign in to comment.