重构项目

This commit is contained in:
ExplodingDragon
2025-11-15 01:09:25 +08:00
parent d67dbf88ae
commit 3492dead8d
34 changed files with 715 additions and 444 deletions

View File

@@ -21,8 +21,8 @@ import (
type ProviderCache struct {
parent core.Backend
cacheRepo *tools.Cache[map[string]string]
cacheBranch *tools.Cache[map[string]*core.BranchInfo]
cacheRepo *tools.KVCache[map[string]string]
cacheBranch *tools.KVCache[map[string]*core.BranchInfo]
cacheBlob cache.Cache
cacheBlobLimit uint64
@@ -88,10 +88,10 @@ func (c *ProviderCache) Branches(ctx context.Context, owner, repo string) (map[s
return ret, err
}
func (c *ProviderCache) Open(ctx context.Context, client *http.Client, owner, repo, commit, path string, headers http.Header) (*http.Response, error) {
func (c *ProviderCache) Open(ctx context.Context, owner, repo, commit, path string, headers http.Header) (*http.Response, error) {
if headers != nil && headers.Get("Range") != "" {
// ignore custom header
return c.parent.Open(ctx, client, owner, repo, commit, path, headers)
return c.parent.Open(ctx, owner, repo, commit, path, headers)
}
key := fmt.Sprintf("%s/%s/%s/%s", owner, repo, commit, path)
lastCache, err := c.cacheBlob.Get(ctx, key)
@@ -125,7 +125,7 @@ func (c *ProviderCache) Open(ctx context.Context, client *http.Client, owner, re
Header: respHeader,
}, nil
}
open, err := c.parent.Open(ctx, client, owner, repo, commit, path, http.Header{})
open, err := c.parent.Open(ctx, owner, repo, commit, path, http.Header{})
if err != nil || open == nil {
if open != nil {
_ = open.Body.Close()