Comment 0 for bug 1663365

Revision history for this message
Kyle Fazzari (kyrofa) wrote :

When Snapcraft fetches stage packages, as of 2.27 it does it individually, which doesn't provide an overall picture of how long pulling all of them will take. This is because fetch_archives(), the method used to do it previously, messes with some filenames so fetching from the cache didn't work. For example:

>>> import snapcraft.internal.repo as repo
>>> r = repo.Ubuntu('/tmp/foo')
>>> with r._apt.archive('/tmp/cache') as apt_cache:
... p = apt_cache['cpp']
... p.mark_install()
... apt_cache.fetch_archives()

Results in 'cpp_4%3a5.3.1-1ubuntu1_amd64.deb' being fetched. Whereas:

>>> import snapcraft.internal.repo as repo
>>> r = repo.Ubuntu('/tmp/foo')
>>> with r._apt.archive('/tmp/cache') as apt_cache:
... p = apt_cache['cpp']
... p.candidate.fetch_binary(<downloaddir>)

Results in cpp_5.3.1-1ubuntu1_amd64.deb being fetched.

Using fetch_binary isn't ideal for the reasons stated above. A better method could be to store files in the cache by hash, but that adds overhead that should be unnecessary. Some investigation into fetch_archives() may be warranted.