pub struct UpdateEngine<S>where
S: UpdateSource,{ /* private fields */ }Expand description
Blocking update orchestrator: check → download → verify → install.
All methods block; the GPUI integration runs them on a background executor.
Implementations§
Source§impl<S> UpdateEngine<S>where
S: UpdateSource,
impl<S> UpdateEngine<S>where
S: UpdateSource,
Sourcepub fn new(source: S, config: EngineConfig) -> UpdateEngine<S>
pub fn new(source: S, config: EngineConfig) -> UpdateEngine<S>
Build an engine from a source and configuration.
Sourcepub fn current_version(&self) -> &Version
pub fn current_version(&self) -> &Version
The configured current version.
Sourcepub fn check(&self) -> Result<Option<Release>, Error>
pub fn check(&self) -> Result<Option<Release>, Error>
Fetch the latest release, returning it only if it is newer than the
current version (otherwise Ok(None)).
§Errors
Propagates source/network/parse errors. A newer release is rejected
instead of returned when the Verification policy cannot be met
(Error::VerificationRequired),
or when its artifact or signature would not be fetched over HTTPS
(Error::InsecureUrl).
Sourcepub fn download(
&self,
release: &Release,
progress: impl FnMut(u64, Option<u64>),
) -> Result<Artifact, Error>
pub fn download( &self, release: &Release, progress: impl FnMut(u64, Option<u64>), ) -> Result<Artifact, Error>
Download the update and verify it according to the configured
policies. Returns the Artifact to hand to install.
Files are fetched over HTTPS only, into a fresh directory that only the
current user can access (or EngineConfig::download_dir, where an
earlier download of the same artifact that still verifies is reused
instead of fetched again). A download
larger than the size the release publishes, or than
EngineConfig::max_download_size, is cut off. The file is then
checked against its SHA-256 and minisign signature (see
Verification and VersionBinding), and on macOS the app inside
must declare the release version and carry the expected code signature
(see BundleVersion and CodeSigning).
With the delta feature (macOS and Linux), published deltas are tried
first: the cheapest chain from the current version, if it is smaller
than the full artifact. Each delta is downloaded, verified under the
same policies, and applied to the files it expects, which are checked
against the hashes recorded in the delta. The result is a directory
holding the rebuilt bundle or executable. If anything in that path
fails — no usable delta, a modified installation, a bad checksum or
signature, a network error — the full release.asset is downloaded
instead, so deltas can never make an update fail.
progress is called as (downloaded_bytes, total_bytes). After a failed
delta attempt it restarts from zero for the full download.
To stop a download from another thread, use
download_cancellable.
§Errors
Returns an error on download failure, if verification fails, if the
policy requires a check the release cannot satisfy
(Error::VerificationRequired),
or, before anything is downloaded, if the update could not be
installed where the app is (check_location).
Sourcepub fn download_cancellable(
&self,
release: &Release,
cancel: &CancelToken,
progress: impl FnMut(u64, Option<u64>),
) -> Result<Artifact, Error>
pub fn download_cancellable( &self, release: &Release, cancel: &CancelToken, progress: impl FnMut(u64, Option<u64>), ) -> Result<Artifact, Error>
download, stopping with
Error::Cancelled once cancel is
cancelled. See CancelToken for when a cancel takes effect. A
cancelled download removes its partial file; a delta attempt that is
cancelled does not fall back to the full download.
§Errors
As download, plus
Error::Cancelled.
Sourcepub fn check_location(&self, release: &Release) -> Result<(), Error>
pub fn check_location(&self, release: &Release) -> Result<(), Error>
Check that release could be installed where the app is, without
downloading anything: see install::check_location.
download runs this first; call it yourself to tell
the user before offering the download.
§Errors
Error::Location when the app runs from a
read-only place, such as a disk image or an App Translocation copy, and
Error::Permission when the user may not
write next to it.
Sourcepub fn remove_leftovers(&self)
pub fn remove_leftovers(&self)
Remove what an earlier install left beside the install root because
the old version was still running, such as the previous .exe on
Windows: see install::remove_leftovers. Call it at startup.
Sourcepub fn ownership(&self, hints: &OwnershipHints) -> Ownership
pub fn ownership(&self, hints: &OwnershipHints) -> Ownership
Who keeps the installed app up to date: the app itself, a package
manager, or the packager. See install::ownership. When it is not
Ownership::SelfUpdate, tell the user how to update instead of
offering to. When the install root is unknown, the app is taken to
update itself.
Auto Trait Implementations§
impl<S> Freeze for UpdateEngine<S>where
S: Freeze,
impl<S> RefUnwindSafe for UpdateEngine<S>where
S: RefUnwindSafe,
impl<S> Send for UpdateEngine<S>
impl<S> Sync for UpdateEngine<S>
impl<S> Unpin for UpdateEngine<S>where
S: Unpin,
impl<S> UnsafeUnpin for UpdateEngine<S>where
S: UnsafeUnpin,
impl<S> UnwindSafe for UpdateEngine<S>where
S: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more