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

[Suggestion] The /update API should ideally respond after the icon has been updated. #26

Open
BTBMan opened this issue May 14, 2024 · 6 comments

Comments

@BTBMan
Copy link

BTBMan commented May 14, 2024

Hi, I want the response after Update complete, can you make this happen? thanks.

Or we can control this behavior by a parameter of the /update API.

image
@cyberalien
Copy link
Member

You can add a custom end point for that.

Current behavior is intentional because:

  • Update is not instant. This is because on live servers update is triggered by GitHub actions when icon sets are updated, which is triggered by push to GitHub repo. Often there are multiple commits, which would trigger action in short time span, so 1 minute delay is used to make sure all commits are pushed before update. Also I've ran into situation when pulling repo too quickly after update returns old data instead of latest commit (probably this github bug has been fixed now), delay fixes that.
  • Protection for update end point is basic, its just one parameter. If response is instant and identical regardless of parameters, visitor does not know if parameter is correct. Since update could be resource intensive, you don't want someone to guess your keyword and spam update end point.

@cyberalien
Copy link
Member

To change behavior or to add a custom end point, see src/http/responses/update.ts

Function triggerIconSetsUpdate() triggers actual update and it accepts a callback as parameter, which is called when done with boolean parameter that contains status. So you can use that to send custom response based on status.

Make sure there are no concurrent triggerIconSetsUpdate() runs. It might cause high memory usage when multiple identical operation are executed.

@BTBMan
Copy link
Author

BTBMan commented May 14, 2024

Ok, thanks!

If I just want to update my custom icons which are in the icons folder. Is there a way to do this? without updating the new version of iconify-sets in GitHub.

@cyberalien
Copy link
Member

This should be doable, but requires some refactoring.

I'll get back to you on this and bug report a bit later this week.

@BTBMan
Copy link
Author

BTBMan commented May 14, 2024

Wow, thanks a lot!!! 😆

@cyberalien
Copy link
Member

Added code for that.

Each importer has unique index, same as order of importers in src/config/icon-sets.ts. If you have not modified it, importer for icons directory will have index of 1.

To trigger update only for that importer, replace triggerIconSetsUpdate() in src/http/responses/update.ts with triggerIconSetsUpdate(1)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants