跳到主要内容

Claude Cage · 面向 Claude 的隔离开发环境,支持桌面工作台、多账号、远程部署与移动端连接。上游 Lee-xeo/Claude-Cage 完整源码镜像,非灵栈原创;主许可 MIT,第三方组件遵循各自许可。来源:https://github.com/Lee-xeo/Claude-Cage 。手动同步,不附带 Release 安装包。

浏览文件

0014-configurable-image-cache.patch

41 行 · 1.7 KB历史下载
1diff --git a/pkg/downloader/downloader.go b/pkg/downloader/downloader.go
2index c5977d8..3dfa402 100644
3--- a/pkg/downloader/downloader.go
4+++ b/pkg/downloader/downloader.go
5@@ -80,9 +80,15 @@ func (o *options) apply(opts []Opt) error {
6
7 type Opt func(*options) error
8
9-// WithCache enables caching using filepath.Join(os.UserCacheDir(), "lima") as the cache dir.
10+// WithCache uses Cage's environment volume when configured, or the user's Lima cache.
11 func WithCache() Opt {
12 return func(o *options) error {
13+ if dir := os.Getenv("CAGE_LIMA_CACHE_DIR"); dir != "" {
14+ if !filepath.IsAbs(dir) {
15+ return fmt.Errorf("CAGE_LIMA_CACHE_DIR must be absolute")
16+ }
17+ return WithCacheDir(dir)(o)
18+ }
19 ucd, err := os.UserCacheDir()
20 if err != nil {
21 return err
22diff --git a/pkg/downloader/resume_test.go b/pkg/downloader/resume_test.go
23index 896242c..5a76bdd 100644
24--- a/pkg/downloader/resume_test.go
25+++ b/pkg/downloader/resume_test.go
26@@ -37,10 +37,14 @@ func TestPinnedDownloadResumesInterruptedBody(t *testing.T) {
27 }))
28 defer s.Close()
29 cache := t.TempDir()
30- r, err := Download(t.Context(), "", s.URL, WithCacheDir(cache), WithExpectedDigest(digest.FromString(data)))
31+ t.Setenv("CAGE_LIMA_CACHE_DIR", cache)
32+ r, err := Download(t.Context(), "", s.URL, WithCache(), WithExpectedDigest(digest.FromString(data)))
33 if err != nil {
34 t.Fatal(err)
35 }
36+ if rel, err := filepath.Rel(cache, r.CachePath); err != nil || !filepath.IsLocal(rel) {
37+ t.Fatalf("download landed outside chosen cache: %q", r.CachePath)
38+ }
39 got, err := os.ReadFile(r.CachePath)
40 if err != nil || string(got) != data || calls.Load() != 2 {
41 t.Fatalf("result %q, calls %d, error %v", got, calls.Load(), err)