Exemple #1
0
        /// <summary>
        /// There are a bunch of scenarios when a new DS version brakes Torch so a manual installation will be requeried.
        /// Don't rely on any Torch component here, casue it may be broken, it uses the same implementation that Torch uses.
        /// </summary>
        static async void ForceTorchManualUpdate()
        {
            InformationalVersion torchVersion;
            var versionString = Assembly.LoadFrom(_torchAssembly)
                                .GetCustomAttribute <AssemblyInformationalVersionAttribute>()
                                .InformationalVersion;

            if (!InformationalVersion.TryParse(versionString, out torchVersion))
            {
                throw new TypeLoadException("UpdateMeGuardian: Unable to parse the Torch version from the assembly.");
            }

            var torchLatestVersion = await JenkinsQuery.Instance.GetLatestVersion(torchVersion.Branch);

            if (torchLatestVersion == null)
            {
                Log.Warn("UpdateMeGuardian: Failed to fetch latest version.");
                return;
            }

            if (torchLatestVersion.Version > torchVersion)
            {
                //Util.Log($"Updating Torch from version {UpdateMePlugin.Instance.Torch.TorchVersion} to version {job.Version}");
                var updateName = Path.Combine(_tmpDirectory, "torchupdate.zip");
                if (!await JenkinsQuery.Instance.DownloadRelease(torchLatestVersion, updateName))
                {
                    Log.Warn("UpdateMeGuardian: Failed to download new release!");
                    return;
                }
                UpdateFromZip(updateName, Directory.GetCurrentDirectory());
                File.Delete(updateName);
                Log.Info($"UpdateMeGuardian: Torch version {torchLatestVersion.Version} has been installed.");
            }
        }
Exemple #2
0
        public static bool TryParse(string input, out InformationalVersion version)
        {
            version = default(InformationalVersion);
            var trim = input.TrimStart('v');
            var info = trim.Split(new[] { '-' }, 2);

            if (!Version.TryParse(info[0], out Version result))
            {
                return(false);
            }

            version = new InformationalVersion {
                Version = result
            };

            if (info.Length > 1)
            {
                version.Branch = info[1];
            }

            return(true);
        }