public async Task <ApplicationVersion> GetLatestVersionInformation(Guid applicationId, string version) { IApplicationVersionStore applicationVersionStore = _storeFactory.GetApplicationVersionStore(_userAgent); var latest = await applicationVersionStore.GetLatest(applicationId); return(latest); }
public async Task <bool> IsLatestVersion(Guid applicationId, string version) { IApplicationVersionStore applicationVersionStore = _storeFactory.GetApplicationVersionStore(_userAgent); var latest = await applicationVersionStore.GetLatest(applicationId); return(!NewerVersionExist(version, latest.ToString())); }
/// <summary> /// Downloads the package for the latest version of the application ID. /// </summary> /// <param name="applicationId">The GUID of the application for which to download the latest version</param> /// <returns>The path to the downloaded Package file</returns> public async Task <string> DownloadLatestVersionPackage(Guid applicationId) { try { IApplicationVersionStore applicationVersionStore = _storeFactory.GetApplicationVersionStore(_userAgent); var latest = await applicationVersionStore.GetLatest(applicationId); Log.To.Main.Add($"Downloading package from {latest.PackageUri}"); using (var webClient = new WebClient()) { var path = Path.GetTempPath(); var fileName = Path.Combine(path, Guid.NewGuid().ToString("N") + ".zip"); webClient.Headers.Add(HttpRequestHeader.UserAgent, _userAgent); webClient.UseDefaultCredentials = true; webClient.Headers.Add("Accept", "application/x-zip-compressed"); await webClient.DownloadFileTaskAsync(latest.PackageUri, fileName); Log.To.Main.Add("Package downloaded"); if (!GetMd5(fileName).Equals(latest.Md5)) { throw new Exception("Checksum verification failed for downloaded package"); } return(fileName); } } catch (Exception ex) { Log.To.Main.Add($"Error when downloading package: {ex.GetNestedMessages()}"); throw; } }