update method

FutureOr<ReleaseUpdateResult?> update({
  1. Release? targetRelease,
  2. Version? targetVersion,
  3. String? platform,
  4. bool exactPlatform = false,
  5. bool force = false,
  6. bool verbose = false,
})

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 when true ensures that the update is for the exact platform parameter.
  • force when true performs the update even when already updated to the targetRelease and targetVersion.

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);
}