View Source NervesHubLink.ArchiveManager (nerves_hub_link v2.6.0)

GenServer for handling downloading archives from NervesHub

Your NervesHubLink client will tell the manager when to download an archive and the Manager will tell your client when it's done downloading so you can act on it.

You are expected to remove the file when you're done with it and track that it has been applied to prevent downloading again.

Summary

Functions

Must be called when an archive payload is dispatched from NervesHub. the map must contain a "url" key.

Returns the UUID of the currently downloading archive, or nil.

Returns the current status of the archive manager

Types

status()

@type status() :: :idle | :downloading | :done | :update_rescheduled

t()

@type t() :: %NervesHubLink.ArchiveManager{
  archive_info: nil | NervesHubLink.Message.ArchiveInfo.t(),
  data_path: Path.t(),
  download: nil | GenServer.server(),
  file_path: Path.t(),
  status: status(),
  temp_file_path: Path.t(),
  update_reschedule_timer: nil | :timer.tref()
}

Functions

apply_archive(manager \\ __MODULE__, archive_info, verification_keys)

@spec apply_archive(GenServer.server(), NervesHubLink.Message.ArchiveInfo.t(), [
  binary()
]) :: status()

Must be called when an archive payload is dispatched from NervesHub. the map must contain a "url" key.

currently_downloading_uuid(manager \\ __MODULE__)

@spec currently_downloading_uuid(GenServer.server()) :: uuid :: String.t() | nil

Returns the UUID of the currently downloading archive, or nil.

status(manager \\ __MODULE__)

@spec status(GenServer.server()) :: status()

Returns the current status of the archive manager

valid_archive?(file_path, public_keys)