private async void Refresh(bool isCaching = true, bool checkForUpdates = false)
        {
            var releases = await _releaseManager.GetReleases(isCaching);

            var updateBranch = (await _releaseManager.GetTargetRelease())?.Branch;

            UpdateReleases = releases
                             .GroupBy(p => p.Branch)
                             .Select(p => p.OrderBy(q => q.Version).Last())
                             .Where(p => p.MergedTo == null)
                             .OrderBy(p => p.Branch)
                             .ToArray();
            UpdateRelease = UpdateReleases.FirstOrDefault(p => p.Branch == updateBranch);

            var rollbackVersion = RollbackRelease?.Version;

            RollbackReleases = _releaseManager.PreviousVersions
                               .Select(p => releases.FirstOrDefault(q => q.Version == p))
                               .Where(p => p != null && p.Version != _releaseManager.CurrentVersion)
                               .ToArray();
            RollbackRelease = RollbackReleases.FirstOrDefault(p => p.Version == rollbackVersion) ?? RollbackReleases.FirstOrDefault();

            if (checkForUpdates && IsUpdatingAutomatically && UpdateRelease != null)
            {
                var installedVersion = Assembly.GetExecutingAssembly().GetName().Version;
                if (UpdateRelease.Version > installedVersion)
                {
                    Update(UpdateRelease);
                }
            }
        }
Пример #2
0
        public async Task <UpdateInfo?> GetLatestAsync(CancellationToken cancellationToken)
        {
            var releases = await GetAllAsync(cancellationToken);

            if (releases.Any())
            {
                UpdateReleases = SortAndFilterReleases(releases).ToList();
                return(UpdateReleases.FirstOrDefault());
            }
            return(null);
        }
Пример #3
0
        public UpdateInfo?UpdateCurrentVersion(string?fallbackVersion)
        {
            UpdateInfo?foundVersion = null;

            if (UpdateReleases != null && UpdateReleases.Any())
            {
                var searchVersion = CurrentVersion ?? fallbackVersion;
                if (searchVersion != null)
                {
                    foundVersion = UpdateReleases.SingleOrDefault(li => string.Compare(li.GetVersion(),
                                                                                       searchVersion, StringComparison.OrdinalIgnoreCase) == 0);
                }
                foundVersion ??= UpdateReleases.FirstOrDefault();
            }
            CurrentVersion = foundVersion?.GetVersion() ?? fallbackVersion;
            return(foundVersion);
        }