Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add named metadata event #41601

Merged
merged 1 commit into from
Nov 20, 2023
Merged

Conversation

ArtificialOwl
Copy link
Member

This adds:

  • a new event MetadataNamedEvent,
  • an optional parameter to the existing occ files:scan --generate-metadata [name] command.

The idea is to provide a last param to the IFilesMetadataManager::refreshMetadata() that assign a name to the event.
Any app listening to the MetadataNameEvent will use getName() to confirm the event is related to itself and manage the refresh of metadata the same way it would manage the Live and/or Background Event.

This way, we can ask a refresh of the metadata from all files' from the cloud without loosing time refreshing all metadata provided by all apps.

@ArtificialOwl ArtificialOwl added the 3. to review Waiting for reviews label Nov 18, 2023
@ArtificialOwl ArtificialOwl added this to the Nextcloud 28 milestone Nov 18, 2023
@ArtificialOwl ArtificialOwl reopened this Nov 18, 2023
@artonge
Copy link
Contributor

artonge commented Nov 20, 2023

So existing providers need to all listen to this new event?

if ((self::PROCESS_LIVE & $process) !== 0) {
$event = new MetadataLiveEvent($node, $metadata);
} elseif ((self::PROCESS_NAMED & $process) !== 0 && $namedEvent !== '') {
$event = new MetadataNamedEvent($node, $metadata, $namedEvent);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So named event is always live, or always backgrounded?
Why the name is not an optional parameter for both MetadataLiveEvent and MetadataBackgroundEvent?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because it would require a check condition on every Live/Background listeners

@ArtificialOwl
Copy link
Member Author

So existing providers need to all listen to this new event?

no, this is purely optionnal; only if they want to called via a specific occ command.
It should only be implemented if they want to provide a faster way to only add their own metadata on a scan

@come-nc
Copy link
Contributor

come-nc commented Nov 20, 2023

So the passed name does not need to match a metadata name, it’s like a tag used by some providers?

@ArtificialOwl
Copy link
Member Author

So the passed name does not need to match a metadata name, it’s like a tag used by some providers?

yes, as we don't communicate via provider we cannot enforce provider_id

@ArtificialOwl
Copy link
Member Author

ArtificialOwl commented Nov 20, 2023

The idea behind this is mostly to remove the custom files scan from files_fulltextsearch and use metadata to store the status of the index of a document there.

However, starting a full index of your current document will also trigger some heavy process from the extraction of metadata from photos.

Using NamedEvent, I can trigger a scan of files to only update metadata related to fulltextsearch

Copy link
Contributor

@come-nc come-nc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I get the idea, I’m not entirely sure this won’t be cause for trouble.
Especially there is nothing to prevent name clash between applications.

apps/files/lib/Command/Scan.php Show resolved Hide resolved
lib/private/FilesMetadata/FilesMetadataManager.php Outdated Show resolved Hide resolved
lib/public/FilesMetadata/Event/MetadataNamedEvent.php Outdated Show resolved Hide resolved
@blizzz blizzz mentioned this pull request Nov 20, 2023
5 tasks
Signed-off-by: Maxence Lange <maxence@artificial-owl.com>
@ArtificialOwl ArtificialOwl force-pushed the enh/noid/named-metadata-event branch from f9ec06b to 22d6c8d Compare November 20, 2023 14:36
Copy link
Contributor

@artonge artonge left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Feels highly specific, but I do not see any other solution.

@ArtificialOwl ArtificialOwl merged commit ae71ed1 into master Nov 20, 2023
50 checks passed
@ArtificialOwl ArtificialOwl deleted the enh/noid/named-metadata-event branch November 20, 2023 23:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3. to review Waiting for reviews
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants