public static async Task <string> GetPreviousVersionGuid(string branch, string versionGuid, bool retry = true)
        {
            StudioDeployLogs deployLogs = await GetDeployLogs(branch);

            if (deployLogs.LookupFromGuid.ContainsKey(versionGuid))
            {
                StudioDeployLog currentLog      = deployLogs.LookupFromGuid[versionGuid];
                int             previousVersion = currentLog.Version - 1;

                if (deployLogs.LookupFromVersion.ContainsKey(previousVersion))
                {
                    StudioDeployLog previousLog = deployLogs.LookupFromVersion[previousVersion];
                    return(previousLog.VersionGuid);
                }
                else
                {
                    throw new Exception("Could not resolve previous version.");
                }
            }
            else if (retry)
            {
                // The cache might be invalid now? Try rebuilding it.
                Logs.Remove(branch);
                return(await GetPreviousVersionGuid(branch, versionGuid, false));
            }
            else
            {
                throw new Exception("Unknown version guid: " + versionGuid);
            }
        }
        public static async Task <StudioDeployLogs> GetDeployLogs(string branch)
        {
            if (!Logs.ContainsKey(branch))
            {
                string deployHistoryUrl = "https://s3.amazonaws.com/setup." + branch + ".com/DeployHistory.txt";
                string deployHistory;

                using (WebClient http = new WebClient())
                    deployHistory = await http.DownloadStringTaskAsync(deployHistoryUrl);

                StudioDeployLogs deployLogs = new StudioDeployLogs(deployHistory);
                Logs.Add(branch, deployLogs);
            }

            return(Logs[branch]);
        }