summary refs log tree commit diff
path: root/LibGitTest/WebRepoSource.cs
diff options
context:
space:
mode:
authorTheArcaneBrony <myrainbowdash949@gmail.com>2023-06-05 03:25:53 +0200
committerTheArcaneBrony <myrainbowdash949@gmail.com>2023-06-05 03:25:53 +0200
commit51d820e22a4517dbb06d38a4f07f7c48522ef811 (patch)
tree4a7749cf77223dff2414fd4b73cb17df43d7449e /LibGitTest/WebRepoSource.cs
downloadGitTools-51d820e22a4517dbb06d38a4f07f7c48522ef811.tar.xz
Initial commit HEAD master
Diffstat (limited to '')
-rw-r--r--LibGitTest/WebRepoSource.cs28
1 files changed, 28 insertions, 0 deletions
diff --git a/LibGitTest/WebRepoSource.cs b/LibGitTest/WebRepoSource.cs
new file mode 100644

index 0000000..39d9b79 --- /dev/null +++ b/LibGitTest/WebRepoSource.cs
@@ -0,0 +1,28 @@ +using LibGit.Interfaces; + +namespace LibGitTest; + +public class WebRepoSource : IRepoSource +{ + private const bool _debug = false; + public WebRepoSource(string basePath) + { + BasePath = basePath; + } + + public string BasePath { get; set; } + + public async Task<Stream> GetFileStream(string path) + { + 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<bool> HasObjectCached(string currentCommitId) + { + return Random.Shared.Next(0, 2) == 1; + } +} \ No newline at end of file