Ejemplo n.º 1
0
        private void TimerCallback(object unusedState)
        {
            string errorMessage = null;
            InstallerPreRunChecker prerunChecker = new InstallerPreRunChecker(this.tracer, string.Empty);
            IProductUpgrader       productUpgrader;
            bool deleteExistingDownloads = true;

            if (ProductUpgraderFactory.TryCreateUpgrader(out productUpgrader, this.tracer, out errorMessage))
            {
                if (prerunChecker.TryRunPreUpgradeChecks(out string _) && this.TryDownloadUpgrade(productUpgrader, out errorMessage))
                {
                    deleteExistingDownloads = false;
                }
            }

            if (errorMessage != null)
            {
                this.tracer.RelatedError(errorMessage);
            }

            if (deleteExistingDownloads)
            {
                ProductUpgraderInfo.DeleteAllInstallerDownloads();
            }
        }
Ejemplo n.º 2
0
        private bool TryDownloadUpgrade(IProductUpgrader productUpgrader, out string errorMessage)
        {
            using (ITracer activity = this.tracer.StartActivity("Checking for product upgrades.", EventLevel.Informational))
            {
                Version newerVersion  = null;
                string  detailedError = null;
                if (!productUpgrader.UpgradeAllowed(out errorMessage))
                {
                    return(false);
                }

                if (!productUpgrader.TryQueryNewestVersion(out newerVersion, out detailedError))
                {
                    errorMessage = "Could not fetch new version info. " + detailedError;
                    return(false);
                }

                if (newerVersion == null)
                {
                    // Already up-to-date
                    // Make sure there a no asset installers remaining in the Downloads directory. This can happen if user
                    // upgraded by manually downloading and running asset installers.
                    ProductUpgraderInfo.DeleteAllInstallerDownloads();
                    errorMessage = null;
                    return(true);
                }

                if (productUpgrader.TryDownloadNewestVersion(out detailedError))
                {
                    errorMessage = null;
                    return(true);
                }
                else
                {
                    errorMessage = "Could not download product upgrade. " + detailedError;
                    return(false);
                }
            }
        }
Ejemplo n.º 3
0
        private bool TryRunUpgrade(out Version newVersion, out string consoleError)
        {
            Version newGVFSVersion = null;
            string  error          = null;

            if (!this.upgrader.UpgradeAllowed(out error))
            {
                ProductUpgraderInfo productUpgraderInfo = new ProductUpgraderInfo(
                    this.tracer,
                    this.fileSystem);
                productUpgraderInfo.DeleteAllInstallerDownloads();
                this.output.WriteLine(error);
                consoleError = null;
                newVersion   = null;
                return(true);
            }

            if (!this.LaunchInsideSpinner(
                    () =>
            {
                if (!this.preRunChecker.TryRunPreUpgradeChecks(out error))
                {
                    return(false);
                }

                if (!this.TryCheckIfUpgradeAvailable(out newGVFSVersion, out error))
                {
                    return(false);
                }

                this.LogInstalledVersionInfo();

                if (newGVFSVersion != null && !this.TryDownloadUpgrade(newGVFSVersion, out error))
                {
                    return(false);
                }

                return(true);
            },
                    "Downloading"))
            {
                newVersion   = null;
                consoleError = error;
                return(false);
            }

            if (newGVFSVersion == null)
            {
                newVersion   = null;
                consoleError = null;
                return(true);
            }

            if (!this.LaunchInsideSpinner(
                    () =>
            {
                if (!this.preRunChecker.TryUnmountAllGVFSRepos(out error))
                {
                    return(false);
                }

                this.mount = true;

                return(true);
            },
                    "Unmounting repositories"))
            {
                newVersion   = null;
                consoleError = error;
                return(false);
            }

            if (!this.LaunchInsideSpinner(
                    () =>
            {
                if (!this.preRunChecker.IsInstallationBlockedByRunningProcess(out error))
                {
                    return(false);
                }

                return(true);
            },
                    "Checking for blocking processes."))
            {
                newVersion   = null;
                consoleError = error;
                return(false);
            }

            if (!this.upgrader.TryRunInstaller(this.LaunchInsideSpinner, out consoleError))
            {
                newVersion = null;
                return(false);
            }

            newVersion   = newGVFSVersion;
            consoleError = null;
            return(true);
        }
Ejemplo n.º 4
0
        private bool TryRunProductUpgrade()
        {
            string  errorOutputFormat   = Environment.NewLine + "ERROR: {0}";
            string  message             = null;
            string  cannotInstallReason = null;
            Version newestVersion       = null;

            bool isInstallable = this.TryCheckUpgradeInstallable(out cannotInstallReason);

            if (this.Confirmed && !isInstallable)
            {
                this.ReportInfoToConsole($"Cannot upgrade GVFS on this machine.");
                this.Output.WriteLine(errorOutputFormat, cannotInstallReason);
                this.tracer.RelatedError($"{nameof(this.TryRunProductUpgrade)}: Upgrade is not installable. {cannotInstallReason}");
                return(false);
            }

            if (!this.upgrader.UpgradeAllowed(out message))
            {
                ProductUpgraderInfo.DeleteAllInstallerDownloads();
                this.ReportInfoToConsole(message);
                return(true);
            }

            if (!this.TryRunUpgradeChecks(out newestVersion, out message))
            {
                this.Output.WriteLine(errorOutputFormat, message);
                this.tracer.RelatedError($"{nameof(this.TryRunProductUpgrade)}: Upgrade checks failed. {message}");
                return(false);
            }

            if (newestVersion == null)
            {
                // Make sure there a no asset installers remaining in the Downloads directory. This can happen if user
                // upgraded by manually downloading and running asset installers.
                ProductUpgraderInfo.DeleteAllInstallerDownloads();
                this.ReportInfoToConsole(message);
                return(true);
            }

            if (this.Confirmed)
            {
                this.ReportInfoToConsole(message);

                if (!isInstallable)
                {
                    this.tracer.RelatedError($"{nameof(this.TryRunProductUpgrade)}: {message}");
                    this.Output.WriteLine(errorOutputFormat, message);
                    return(false);
                }

                if (!this.TryRunInstaller(out message))
                {
                    this.tracer.RelatedError($"{nameof(this.TryRunProductUpgrade)}: Could not launch upgrade tool. {message}");
                    this.Output.WriteLine(errorOutputFormat, "Could not launch upgrade tool. " + message);
                    return(false);
                }
            }
            else
            {
                string advisoryMessage = string.Join(
                    Environment.NewLine,
                    GVFSConstants.UpgradeVerbMessages.UnmountRepoWarning,
                    GVFSConstants.UpgradeVerbMessages.UpgradeInstallAdvice);
                this.ReportInfoToConsole(message + Environment.NewLine + Environment.NewLine + advisoryMessage + Environment.NewLine);
            }

            return(true);
        }
        private bool TryRunProductUpgrade()
        {
            string  errorOutputFormat   = Environment.NewLine + "ERROR: {0}";
            string  message             = null;
            string  cannotInstallReason = null;
            Version newestVersion       = null;

            bool isInstallable = this.TryCheckUpgradeInstallable(out cannotInstallReason);

            if (this.ShouldRunUpgraderTool() && !isInstallable)
            {
                this.ReportInfoToConsole($"Cannot upgrade GVFS on this machine.");
                this.Output.WriteLine(errorOutputFormat, cannotInstallReason);
                return(false);
            }

            if (!this.upgrader.UpgradeAllowed(out message))
            {
                ProductUpgraderInfo productUpgraderInfo = new ProductUpgraderInfo(
                    this.tracer,
                    this.fileSystem);
                productUpgraderInfo.DeleteAllInstallerDownloads();
                productUpgraderInfo.RecordHighestAvailableVersion(highestAvailableVersion: null);
                this.ReportInfoToConsole(message);
                return(true);
            }

            if (!this.TryRunUpgradeChecks(out newestVersion, out message))
            {
                this.Output.WriteLine(errorOutputFormat, message);
                this.tracer.RelatedError($"{nameof(this.TryRunProductUpgrade)}: Upgrade checks failed. {message}");
                return(false);
            }

            if (newestVersion == null)
            {
                // Make sure there a no asset installers remaining in the Downloads directory. This can happen if user
                // upgraded by manually downloading and running asset installers.
                ProductUpgraderInfo productUpgraderInfo = new ProductUpgraderInfo(
                    this.tracer,
                    this.fileSystem);
                productUpgraderInfo.DeleteAllInstallerDownloads();
                this.ReportInfoToConsole(message);
                return(true);
            }

            if (this.ShouldRunUpgraderTool())
            {
                this.ReportInfoToConsole(message);

                if (!isInstallable)
                {
                    this.tracer.RelatedError($"{nameof(this.TryRunProductUpgrade)}: {message}");
                    this.Output.WriteLine(errorOutputFormat, message);
                    return(false);
                }

                // If we are on a platform that does not support nuget verification, and user has not
                // specified the --no-verify flag, then print a helpful message here.
                if (!GVFSPlatform.Instance.UnderConstruction.SupportsNuGetVerification && !this.NoVerify)
                {
                    string packageVerificationNotSupportedMessage = @"
NuGet package verification is not supported on this platform. In order to run upgrade, you must run upgrade without NuGet package verification.
To run upgrade without NuGet verification include the --no-verify option.
";
                    this.ReportInfoToConsole(packageVerificationNotSupportedMessage);
                    return(false);
                }

                if (!this.TryRunInstaller(out message))
                {
                    this.tracer.RelatedError($"{nameof(this.TryRunProductUpgrade)}: Could not launch upgrade tool. {message}");
                    this.Output.WriteLine(errorOutputFormat, "Could not launch upgrade tool. " + message);
                    return(false);
                }
            }
            else
            {
                string advisoryMessage = string.Join(
                    Environment.NewLine,
                    GVFSConstants.UpgradeVerbMessages.UnmountRepoWarning,
                    GVFSPlatform.Instance.Constants.UpgradeInstallAdviceMessage);
                this.ReportInfoToConsole(message + Environment.NewLine + Environment.NewLine + advisoryMessage + Environment.NewLine);
            }

            return(true);
        }
Ejemplo n.º 6
0
        private bool TryRunProductUpgrade()
        {
            string  errorOutputFormat   = Environment.NewLine + "ERROR: {0}";
            string  message             = null;
            string  cannotInstallReason = null;
            Version newestVersion       = null;

            bool isInstallable = this.TryCheckUpgradeInstallable(out cannotInstallReason);

            if (this.ShouldRunUpgraderTool() && !isInstallable)
            {
                this.ReportInfoToConsole($"Cannot upgrade Scalar on this machine.");
                this.Output.WriteLine(errorOutputFormat, cannotInstallReason);
                return(false);
            }

            if (!this.upgrader.UpgradeAllowed(out message))
            {
                ProductUpgraderInfo productUpgraderInfo = new ProductUpgraderInfo(
                    this.tracer,
                    this.fileSystem);
                productUpgraderInfo.DeleteAllInstallerDownloads();
                productUpgraderInfo.RecordHighestAvailableVersion(highestAvailableVersion: null);
                this.ReportInfoToConsole(message);
                return(true);
            }

            if (!this.TryRunUpgradeChecks(out newestVersion, out message))
            {
                this.Output.WriteLine(errorOutputFormat, message);
                this.tracer.RelatedError($"{nameof(this.TryRunProductUpgrade)}: Upgrade checks failed. {message}");
                return(false);
            }

            if (newestVersion == null)
            {
                // Make sure there a no asset installers remaining in the Downloads directory. This can happen if user
                // upgraded by manually downloading and running asset installers.
                ProductUpgraderInfo productUpgraderInfo = new ProductUpgraderInfo(
                    this.tracer,
                    this.fileSystem);
                productUpgraderInfo.DeleteAllInstallerDownloads();
                this.ReportInfoToConsole(message);
                return(true);
            }

            if (this.ShouldRunUpgraderTool())
            {
                this.ReportInfoToConsole(message);

                if (!isInstallable)
                {
                    this.tracer.RelatedError($"{nameof(this.TryRunProductUpgrade)}: {message}");
                    this.Output.WriteLine(errorOutputFormat, message);
                    return(false);
                }

                if (!this.TryRunInstaller(out message))
                {
                    this.tracer.RelatedError($"{nameof(this.TryRunProductUpgrade)}: Could not launch upgrade tool. {message}");
                    this.Output.WriteLine(errorOutputFormat, "Could not launch upgrade tool. " + message);
                    return(false);
                }
            }
            else
            {
                string upgradeMessage = string.Format("{1}{0}{0}{2}{0}",
                                                      Environment.NewLine, message, ScalarConstants.UpgradeVerbMessages.UpgradeInstallAdvice);
                this.ReportInfoToConsole(upgradeMessage);
            }

            return(true);
        }
Ejemplo n.º 7
0
        private bool TryRunUpgrade(out Version newVersion, out string consoleError)
        {
            newVersion = null;

            Version newGVFSVersion = null;
            string  error          = null;

            if (!this.upgrader.UpgradeAllowed(out error))
            {
                ProductUpgraderInfo.DeleteAllInstallerDownloads();
                this.output.WriteLine(error);
                consoleError = null;
                return(true);
            }

            if (!this.LaunchInsideSpinner(
                    () =>
            {
                if (!this.TryCheckIfUpgradeAvailable(out newGVFSVersion, out error))
                {
                    return(false);
                }

                this.LogInstalledVersionInfo();

                if (!this.preRunChecker.TryRunPreUpgradeChecks(out error))
                {
                    return(false);
                }

                if (!this.TryDownloadUpgrade(newGVFSVersion, out error))
                {
                    return(false);
                }

                return(true);
            },
                    "Downloading"))
            {
                consoleError = error;
                return(false);
            }

            if (!this.LaunchInsideSpinner(
                    () =>
            {
                if (!this.preRunChecker.TryUnmountAllGVFSRepos(out error))
                {
                    return(false);
                }

                this.mount = true;

                return(true);
            },
                    "Unmounting repositories"))
            {
                consoleError = error;
                return(false);
            }

            if (!this.upgrader.TryRunInstaller(this.LaunchInsideSpinner, out consoleError))
            {
                return(false);
            }

            newVersion   = newGVFSVersion;
            consoleError = null;
            return(true);
        }