public async Task PullAsync(CancellationToken cancellationToken = default) { if (bool.TryParse(_apiOptions.SkipGitOperations, out var val) && val) { _logger.LogWarning("Skip git operations due to configuration."); return; } var assetDbFolder = Path.Combine(_apiOptions.AssetLocation, Constants.AssetDbFolder); if (Directory.Exists(assetDbFolder)) { Directory.Delete(assetDbFolder, true); } var retryTimes = 0; while (retryTimes <= 3 && !Directory.Exists(assetDbFolder)) { retryTimes++; var repoUrl = $"https://{_apiOptions.GitHubDbRepoApiToken}@github.com/{_apiOptions.GitHubDbRepoUserName}/{_apiOptions.GitHubDbRepoName}.git"; var command = $"git clone -b {_apiOptions.GitHubDbRepoBranchName} --single-branch {repoUrl} {assetDbFolder}"; command += $" && cd {assetDbFolder}"; command += " && git config --local user.name \"API Server\""; command += $" && git config --local user.email \"{_apiOptions.AdminEmail}\""; if (retryTimes > 1) { _logger.LogInformation($"Retry: {retryTimes}... starting to pull DB repo."); } var output = await _commandClient.RunAsync(command, cancellationToken); if (retryTimes > 1) { _logger.LogInformation($"Retry: {retryTimes}, cmd: {command}{Environment.NewLine}"); } _logger.LogInformation(output); } if (!Directory.Exists(assetDbFolder)) { _logger.LogError("Pull DB repo failed."); } }