summary refs log tree commit diff
path: root/LibGitTest/WebRepoSource.cs
diff options
context:
space:
mode:
Diffstat (limited to 'LibGitTest/WebRepoSource.cs')
-rw-r--r--LibGitTest/WebRepoSource.cs13
1 files changed, 11 insertions, 2 deletions
diff --git a/LibGitTest/WebRepoSource.cs b/LibGitTest/WebRepoSource.cs

index 39d9b79..04f5b29 100644 --- a/LibGitTest/WebRepoSource.cs +++ b/LibGitTest/WebRepoSource.cs
@@ -4,7 +4,7 @@ namespace LibGitTest; public class WebRepoSource : IRepoSource { - private const bool _debug = false; + private const bool _debug = true; public WebRepoSource(string basePath) { BasePath = basePath; @@ -12,9 +12,18 @@ public class WebRepoSource : IRepoSource public string BasePath { get; set; } + public async Task<bool> 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<Stream> GetFileStream(string path) { - var client = new HttpClient(); + 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));