Treatment restoreCache
work/cache::restoreCache
Inputs
⇥ filesystem: Block<FileSystem> (fs/filesystem::FileSystem)
⇥ name: Block<string>
⇥ path: Block<string>
Outputs
↦ finished: Block<void>
↦ missed: Block<void>
↦ restored: Block<void>
Restore a cache of api.melodium.tech.
The current version of the cache name of the run is restored at path of filesystem, such
as a volume of the worker (work/resources::getFileSystem) or the local file system of the
engine, replacing what is there. restored is emitted once it is in place.
The archive is downloaded, checked, decompressed and extracted all at once, into a directory
next to path (<path>.melodium-restore), resuming the download after cuts. Only once the
whole archive is extracted and its SHA-256 is the one api.melodium.tech recorded, path is
removed and the directory renamed into its place: a damaged or tampered archive never reaches
path.
When there is no cache of that name, or it cannot be restored (the API, the download or the
extraction fails, the digest differs), missed is emitted with a warning giving the reason,
and path is left as it was. A miss is never an error: a program falls back by restoring
another name on missed, or by building what the cache would have held.
finished is emitted in every case.
path cannot be the root of filesystem, the archive being extracted next to it. Caches are
only restored by programs run by api.melodium.tech.