Skip to content

Commit d896b79

Browse files
authored
Merge pull request #2047 from CortexFoundation/dev
core/rawdb, triedb/pathdb: fix freezer read-only option
2 parents f94e270 + 1890de9 commit d896b79

File tree

5 files changed

+18
-14
lines changed

5 files changed

+18
-14
lines changed

core/rawdb/freezer_resettable.go

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,11 @@ type freezerOpenFunc = func() (*Freezer, error)
3333
// resettableFreezer is a wrapper of the freezer which makes the
3434
// freezer resettable.
3535
type resettableFreezer struct {
36-
freezer *Freezer
37-
opener freezerOpenFunc
38-
datadir string
39-
lock sync.RWMutex
36+
readOnly bool
37+
freezer *Freezer
38+
opener freezerOpenFunc
39+
datadir string
40+
lock sync.RWMutex
4041
}
4142

4243
// newResettableFreezer creates a resettable freezer, note freezer is
@@ -60,9 +61,10 @@ func newResettableFreezer(datadir string, namespace string, readonly bool, maxTa
6061
return nil, err
6162
}
6263
return &resettableFreezer{
63-
freezer: freezer,
64-
opener: opener,
65-
datadir: datadir,
64+
readOnly: readonly,
65+
freezer: freezer,
66+
opener: opener,
67+
datadir: datadir,
6668
}, nil
6769
}
6870

@@ -74,6 +76,9 @@ func (f *resettableFreezer) Reset() error {
7476
f.lock.Lock()
7577
defer f.lock.Unlock()
7678

79+
if f.readOnly {
80+
return errReadOnly
81+
}
7782
if err := f.freezer.Close(); err != nil {
7883
return err
7984
}

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ require (
66
github.com/Azure/azure-sdk-for-go/sdk/storage/azblob v1.3.2
77
github.com/CortexFoundation/inference v1.0.2-0.20230307032835-9197d586a4e8
88
github.com/CortexFoundation/statik v0.0.0-20210315012922-8bb8a7b5dc66
9-
github.com/CortexFoundation/torrentfs v1.0.65-0.20240528085256-81c24aed642e
9+
github.com/CortexFoundation/torrentfs v1.0.65-0.20240528134905-53a5260396d6
1010
github.com/VictoriaMetrics/fastcache v1.12.2
1111
github.com/arsham/figurine v1.3.0
1212
github.com/aws/aws-sdk-go-v2 v1.27.0

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,8 @@ github.com/CortexFoundation/statik v0.0.0-20210315012922-8bb8a7b5dc66/go.mod h1:
7070
github.com/CortexFoundation/torrentfs v1.0.13-0.20200623060705-ce027f43f2f8/go.mod h1:Ma+tGhPPvz4CEZHaqEJQMOEGOfHeQBiAoNd1zyc/w3Q=
7171
github.com/CortexFoundation/torrentfs v1.0.14-0.20200703071639-3fcabcabf274/go.mod h1:qnb3YlIJmuetVBtC6Lsejr0Xru+1DNmDCdTqnwy7lhk=
7272
github.com/CortexFoundation/torrentfs v1.0.20-0.20200810031954-d36d26f82fcc/go.mod h1:N5BsicP5ynjXIi/Npl/SRzlJ630n1PJV2sRj0Z0t2HA=
73-
github.com/CortexFoundation/torrentfs v1.0.65-0.20240528085256-81c24aed642e h1:XPgiOuI/BQmEYOhDfrEl7e0vksbkBe0meT6YZAd0y3w=
74-
github.com/CortexFoundation/torrentfs v1.0.65-0.20240528085256-81c24aed642e/go.mod h1:RTrewKfZZUqUIudGRYm7SydFQOnAQlmyQ2rggGH0CmA=
73+
github.com/CortexFoundation/torrentfs v1.0.65-0.20240528134905-53a5260396d6 h1:vqyeuougAKbCCe5iajAKXyfi673149dZy0k6RXLs/i0=
74+
github.com/CortexFoundation/torrentfs v1.0.65-0.20240528134905-53a5260396d6/go.mod h1:RTrewKfZZUqUIudGRYm7SydFQOnAQlmyQ2rggGH0CmA=
7575
github.com/CortexFoundation/wormhole v0.0.2-0.20240503144741-71d4d22383f0 h1:pePXS+/6usgcC1G2Ma3pX7fJwoRcgLPyu5SLawrTszc=
7676
github.com/CortexFoundation/wormhole v0.0.2-0.20240503144741-71d4d22383f0/go.mod h1:ipzmPabDgzYKUbXkGVe2gTkBEp+MsDx6pXGiuYzmP6s=
7777
github.com/DATA-DOG/go-sqlmock v1.3.3/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q5eFN3EC/SaM=

vendor/github.com/CortexFoundation/torrentfs/backend/caffe/t.go

Lines changed: 2 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/modules.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ github.com/CortexFoundation/robot/backend
6161
# github.com/CortexFoundation/statik v0.0.0-20210315012922-8bb8a7b5dc66
6262
## explicit; go 1.16
6363
github.com/CortexFoundation/statik
64-
# github.com/CortexFoundation/torrentfs v1.0.65-0.20240528085256-81c24aed642e
64+
# github.com/CortexFoundation/torrentfs v1.0.65-0.20240528134905-53a5260396d6
6565
## explicit; go 1.22
6666
github.com/CortexFoundation/torrentfs
6767
github.com/CortexFoundation/torrentfs/backend

0 commit comments

Comments
 (0)