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

WebAPI: add new method setTags to upsert tags on torrents #22156

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

zze0s
Copy link
Contributor

@zze0s zze0s commented Jan 12, 2025

This is another optimization for torrent management on large scale instances with the goal to minimize the amount of required API calls. Ref #22128

This new function and endpoint torrents/setTags does an upsert to replace the torrent tags and handles the removal and add internally, instead of doing multiple calls to add and remove tags on torrents from the client.

I experimented with adding handling for HTTP PUT since that would be more correct than a POST for this, but did not include those changes.

Should the API version be updated in this PR as well or is that done before a new version is released?

  • Tested locally and works as expected

@@ -937,6 +938,21 @@ bool TorrentImpl::addTag(const Tag &tag)
return true;
}

bool TorrentImpl::setTags(const TagSet &newTags)
Copy link
Member

Choose a reason for hiding this comment

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

I would suggest you move this code to TorrentsController::setTagsAction() instead.
And revert all changes to base/bittorrent.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for reviewing! If that's desired over this solution sure! Is the reasoning to not add additional functions to the core that can be done in the caller with existing methods?

Copy link
Member

Choose a reason for hiding this comment

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

Is the reasoning to not add additional functions to the core that can be done in the caller with existing methods?

Yes. And it seems this operation is exclusive to webapi.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Got it! This made it a much smaller and simpler change 👍

Should API_VERSION in

inline const Utils::Version<3, 2> API_VERSION {2, 11, 3};

Be bumped in this PR to 2.12.0 or is that done separately? Should probably have incremented that with my previous pr, unless it's done just once before a new version is tagged.

@Chocobo1 Chocobo1 added the WebAPI WebAPI-related issues/changes label Jan 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
WebAPI WebAPI-related issues/changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants