Example #1
0
        public async Task <bool> NewVersionInstalled(string fileId, string exeFilePath = null)
        {
            if (exeFilePath.IsBlank())
            {
                exeFilePath = CurrentExe.GetFullPath();
            }

            var loccSHA1 = exeFilePath.SHA1ForFile();
            await _agtState.SetState("Checking for updates", loccSHA1);

            var node = await _conn.GetNode <PublicFileInfo>(ROOTKEY, fileId, SUBKEY);

            if (node == null)
            {
                return(false);
            }
            if (loccSHA1 == node.SHA1)
            {
                await _agtState.SetRunningTask("Already running the latest version.");

                return(false);
            }

            await _agtState.SetRunningTask("Downloading newer version");

            var tmp = await DownloadToTemp(node);

            var bkp = CreateBackupPath(exeFilePath);

            File.Move(exeFilePath, bkp);
            File.Move(tmp, exeFilePath);

            return(true);
        }
Example #2
0
 public Task <AgentState> GetState()
 => _conn.GetNode <AgentState>(NodePath);