update method
Updates the release at storage.
targetRelease
is the desired Release to update to.targetVersion
is the desired Version for the release.platform
is the desired platform of the available Release.exactPlatform
whentrue
ensures that the update is for the exactplatform
parameter.force
whentrue
performs the update even when already updated to thetargetRelease
andtargetVersion
.
Implementation
FutureOr<ReleaseUpdateResult?> update(
{Release? targetRelease,
Version? targetVersion,
String? platform,
bool exactPlatform = false,
bool force = false,
bool verbose = false}) async {
Release? lastRelease;
if (targetVersion == null) {
var release = targetRelease;
release ??= lastRelease ??= await this.lastRelease;
if (release == null) return null;
targetVersion = release.version;
}
platform ??= targetRelease?.platform ?? storage.platform;
if (!force) {
var currentRelease = await storage.currentRelease;
if (currentRelease != null &&
currentRelease.name == name &&
currentRelease.version == targetVersion) {
if (platform == null ||
currentRelease.platform == null ||
currentRelease.platform == platform) {
return null;
}
}
}
var releaseBundle =
await releaseProvider.getReleaseBundle(name, targetVersion, platform);
if (releaseBundle == null && !exactPlatform) {
releaseBundle =
await releaseProvider.getReleaseBundle(name, targetVersion);
}
if (releaseBundle == null) return null;
return storage.updateTo(releaseBundle, force: force, verbose: verbose);
}