using LibGit.Interfaces; namespace LibGitTest; public class WebRepoSource : IRepoSource { private const bool _debug = true; public WebRepoSource(string basePath) { BasePath = basePath; } public string BasePath { get; set; } public async Task FileExists(string path) { using var client = new HttpClient(); if(_debug)Console.WriteLine("Checking file exists: " + Path.Join(BasePath, path)); var response = await client.GetAsync(Path.Join(BasePath, path)); if(_debug)Console.WriteLine("Response status code: " + response.StatusCode); return response.IsSuccessStatusCode; } public async Task GetFileStream(string path) { using var client = new HttpClient(); if(_debug)Console.WriteLine("Fetching file: " + Path.Join(BasePath, path)); var response = await client.GetAsync(Path.Join(BasePath, path)); if(!response.IsSuccessStatusCode) throw new Exception("Failed to fetch file: " + Path.Join(BasePath, path)); return await response.Content.ReadAsStreamAsync(); } public async Task HasObjectCached(string currentCommitId) { return Random.Shared.Next(0, 2) == 1; } }