Skip to content

Draft: appstream: add helper to download metadata from web

Alexey Min requested to merge alexeymin/discover:appstreamdownloader into master

Some distros (for example, Alpine Linux) do not provide appstream data as installable package, instead they host it on the internet (at https://appstream.alpinelinux.org) and software center app has to download them on its own.

Those files are not very large (from few kilobytes to couple of megabytes) but we still need them.

URLs to download archives from are read from JSON files in /usr/share/libdiscover/external-appstream-urls/ directory (QStandardPaths::GenericDataLocation/libdiscover/external-appstream-urls from C++/Qt code).

JSON file format:

{
     "urls": [
         "https://url1",
         "https://url2",
         ...
     ]
}

These JSON files should be provided by the linux distribution.

This class can load any amount of those JSON files, fetch URLs from them and download all files pointed by those URLs to discover's cache directory: ~/.cache/discover/external_appstream_data (aka QStandardPaths::CacheLocation). Use getAppStreamCacheDir() to get this path.

If files are already present in cache and not outdated, they are not downloaded again. Default cache expiration time is 2 days and can be tweaked using setCacheExpirePeriodSecs().

P.S. This change is a requirement before sending any future MRs for Alpine Linux APK backend.

Edited by Alexey Min

Merge request reports