View Source NervesHubLink.ArchiveManager (nerves_hub_link v2.3.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

@type status() :: :idle | :downloading | :done | :update_rescheduled
@type t() :: %NervesHubLink.ArchiveManager{
  archive_info: nil | NervesHubLink.Message.ArchiveInfo.t(),
  archive_public_keys: [binary()],
  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

Link to this function

apply_archive(manager \\ __MODULE__, archive_info)

View Source
@spec apply_archive(GenServer.server(), NervesHubLink.Message.ArchiveInfo.t()) ::
  status()

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

Link to this function

currently_downloading_uuid(manager \\ __MODULE__)

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

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

Link to this function

status(manager \\ __MODULE__)

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

Returns the current status of the archive manager

Link to this function

valid_archive?(file_path, public_keys)

View Source