Skip to content

new occ commands to manage system-tags for files - #48277

Merged
sorbaugh merged 1 commit into
nextcloud:masterfrom
schaarsc:feature/32735-occ-add-tag-to-file-master
Apr 24, 2025
Merged

new occ commands to manage system-tags for files#48277
sorbaugh merged 1 commit into
nextcloud:masterfrom
schaarsc:feature/32735-occ-add-tag-to-file-master

Conversation

@schaarsc

Copy link
Copy Markdown
Contributor

Summary

adds the following commands to the files app:

  • files:tag-add <target> <tags> <access>
  • files:tag-delete <target> <tags> <access>
  • files:tag-delete-all <target>

TODO

  • [ ]

Checklist

return 1;
}

$tags = $this->systemTagObjectMapper->getTagIdsForObjects($targetNode->getId(), 'files');

Check failure

Code scanning / Psalm

InvalidArgument

Argument 1 of OCP\SystemTag\ISystemTagObjectMapper::getTagIdsForObjects expects array<array-key, mixed>|string, but int provided
->setDescription('Add a system-tag to a file or folder')
->addArgument('target', InputArgument::REQUIRED, "file id or path")
->addArgument('tags', InputArgument::REQUIRED, "Name of the tag(s) to add, comma separated")
->addArgument('access', InputArgument::REQUIRED, 'access level of the tag (public, restricted or invisible)');

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It feels weird that access is required for assigning an existing tag

@schaarscschaarscSep 23, 2024

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

I think it is required because

  • the same tagName can exist with different access level
  • I want to work around the missing exif support (Show and edit EXIF Tags photos#226) by automatically creating the tags if it does not exist

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I want to work around the missing exif support (nextcloud/photos#226) by automatically creating the tags if it does not exist

We do support EXIF data, they are currently stored with the FilesMetadata API: https://github.com/nextcloud/photos/blob/f70a0486642e166c69bdd45a480288e05ba5faa9/lib/Listener/ExifMetadataProvider.php

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

please replace EXIF with metadata/xmp...

I'm using the exiftool to extract metadata. The tool is able to extract the XMP information and TagsList is part of XMP, not EXIF

ExifMetadataProvider does indeed store the EXIF part of the metadata, but this only includes things like GPS, Time, size,...

Comment threadapps/files/lib/Command/TagAdd.php Outdated
@schaarsc
schaarscforce-pushed the feature/32735-occ-add-tag-to-file-master branch from 34cde37 to 819385cCompareSeptember 23, 2024 13:21
@github-actions

Copy link
Copy Markdown
Contributor

Hello there,
Thank you so much for taking the time and effort to create a pull request to our Nextcloud project.

We hope that the review process is going smooth and is helpful for you. We want to ensure your pull request is reviewed to your satisfaction. If you have a moment, our community management team would very much appreciate your feedback on your experience with this PR review process.

Your feedback is valuable to us as we continuously strive to improve our community developer experience. Please take a moment to complete our short survey by clicking on the following link: https://cloud.nextcloud.com/apps/forms/s/i9Ago4EQRZ7TWxjfmeEpPkf6

Thank you for contributing to Nextcloud and we hope to hear from you soon!

(If you believe you should not receive this message, you can add yourself to the blocklist.)

@skjnldsv
skjnldsv removed their request for review October 8, 2024 09:05
@blizzzblizzz mentioned this pull request Jan 8, 2025
@skjnldsvskjnldsv mentioned this pull request Jan 14, 2025
@skjnldsvskjnldsv mentioned this pull request Jan 16, 2025
This was referenced Jan 21, 2025
@schaarsc
schaarscforce-pushed the feature/32735-occ-add-tag-to-file-master branch from 819385c to c57f2faCompareJanuary 26, 2025 19:22

@marcelklehrmarcelklehr left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks good

class DeleteAll extends Command {

public function __construct(
private FileUtils $fileUtils,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'm not sure if FileUtils is recommended to be used in apps even if they're in server

@marcelklehr

Copy link
Copy Markdown
Member

@schaarsc Psalm is still failing with an error talking about a wrong argument type

@blizzzblizzz mentioned this pull request Jan 29, 2025
1 task
@blizzzblizzz modified the milestones: Nextcloud 31, Nextcloud 32Jan 29, 2025
Resolvenextcloud#32735
Signed-off-by: schaarsc <schaarsc@users.noreply.github.com>
@schaarsc
schaarscforce-pushed the feature/32735-occ-add-tag-to-file-master branch from c57f2fa to 778ae6aCompareJanuary 29, 2025 18:12
@marcelklehr

Copy link
Copy Markdown
Member

How do we merge since CI fails because it doesn't want to run on forks?

@come-nc

Copy link
Copy Markdown
Contributor

How do we merge since CI fails because it doesn't want to run on forks?

Ask a team lead to force-merge

@sorbaugh
sorbaugh merged commit be54312 into nextcloud:masterApr 24, 2025
@welcome

welcomeBot commented Apr 24, 2025

Copy link
Copy Markdown

Thanks for your first pull request and welcome to the community! Feel free to keep them coming! If you are looking for issues to tackle then have a look at this selection: https://github.com/nextcloud/server/issues?q=is%3Aopen+is%3Aissue+label%3A%22good+first+issue%22

@nextcloud-botnextcloud-bot mentioned this pull request Aug 19, 2025
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Extend occ (tags) with commands to add and remove tags to/from files

10 participants

@schaarsc@marcelklehr@come-nc@joshtrichards@artonge@github-advanced-security@blizzz@skjnldsv@szaimen@sorbaugh