zotero / translation-server

A Node.js-based server to run Zotero translators
Other
117 stars 49 forks source link

Auto updating translators based on metadata #158

Open abaevbog opened 1 year ago

abaevbog commented 1 year ago

Addresses Issue # 1 Automatic translator updates for /web requests. The logic is:

  1. On load, fetch the metadata. Once it is loaded, check if there are new translators in the metadata that are not present in _cache. Load them up as well if so.
  2. Once the request comes in and all relevant translators are fetched, use updateTranslatorIfNeeded function to check if their lastUpdated date is before the lastUpdated date in the metadata. If so, load the translator's code from the repo, update the _cache.
  3. Returns updated (if applicable) translators to translate the items.
abaevbog commented 1 year ago

@dstillman this does not remove translators that are deleted yet. You mentioned there is some kind of mechanism that needed to be checked. If there is nothing special and any deleted translator is just removed from the metadata, we can check if cached translators' IDs exist in the _metadata when it is fetched and remove it from the cache if it is no there (similar to how handleNewTranslators fetches translators that are in the metadata but not in the cache yet) ?