Beispiel #1
0
        public GitHubUpgrader(string currentVersion, ITracer tracer)
        {
            this.installedVersion = new Version(currentVersion);
            this.fileSystem       = new PhysicalFileSystem();
            this.tracer           = tracer;

            string upgradesDirectoryPath = ProductUpgraderInfo.GetUpgradesDirectoryPath();

            this.fileSystem.CreateDirectory(upgradesDirectoryPath);
        }
Beispiel #2
0
        public GitHubUpgrader(
            string currentVersion,
            ITracer tracer,
            PhysicalFileSystem fileSystem,
            GitHubUpgraderConfig upgraderConfig,
            bool dryRun   = false,
            bool noVerify = false)
            : base(currentVersion, tracer, dryRun, noVerify, fileSystem)
        {
            this.Config = upgraderConfig;

            string upgradesDirectoryPath = ProductUpgraderInfo.GetUpgradesDirectoryPath();

            this.fileSystem.CreateDirectory(upgradesDirectoryPath);
        }
Beispiel #3
0
        // TrySetupToolsDirectory -
        // Copies GVFS Upgrader tool and its dependencies to a temporary location in ProgramData.
        // Reason why this is needed - When GVFS.Upgrader.exe is run from C:\ProgramFiles\GVFS folder
        // upgrade installer that is downloaded and run will fail. This is because it cannot overwrite
        // C:\ProgramFiles\GVFS\GVFS.Upgrader.exe that is running. Moving GVFS.Upgrader.exe along with
        // its dependencies to a temporary location inside ProgramData and running GVFS.Upgrader.exe
        // from this temporary location helps avoid this problem.
        public virtual bool TrySetupToolsDirectory(out string upgraderToolPath, out string error)
        {
            string    rootDirectoryPath  = ProductUpgraderInfo.GetUpgradesDirectoryPath();
            string    toolsDirectoryPath = Path.Combine(rootDirectoryPath, ToolsDirectory);
            Exception exception;

            if (TryCreateDirectory(toolsDirectoryPath, out exception))
            {
                string currentPath = ProcessHelper.GetCurrentProcessLocation();
                error = null;
                foreach (string name in UpgraderToolAndLibs)
                {
                    string toolPath        = Path.Combine(currentPath, name);
                    string destinationPath = Path.Combine(toolsDirectoryPath, name);
                    try
                    {
                        File.Copy(toolPath, destinationPath, overwrite: true);
                    }
                    catch (UnauthorizedAccessException e)
                    {
                        error = string.Join(
                            Environment.NewLine,
                            "File copy error - " + e.Message,
                            $"Make sure you have write permissions to directory {rootDirectoryPath} and run {GVFSConstants.UpgradeVerbMessages.GVFSUpgradeConfirm} again.");
                        this.TraceException(e, nameof(this.TrySetupToolsDirectory), $"Error copying {toolPath} to {destinationPath}.");
                        break;
                    }
                    catch (IOException e)
                    {
                        error = "File copy error - " + e.Message;
                        this.TraceException(e, nameof(this.TrySetupToolsDirectory), $"Error copying {toolPath} to {destinationPath}.");
                        break;
                    }
                }

                upgraderToolPath = string.IsNullOrEmpty(error) ? Path.Combine(toolsDirectoryPath, UpgraderToolName) : null;
                return(string.IsNullOrEmpty(error));
            }

            upgraderToolPath = null;
            error            = exception.Message;
            this.TraceException(exception, nameof(this.TrySetupToolsDirectory), $"Error creating upgrade tools directory {toolsDirectoryPath}.");
            return(false);
        }