mirror of
https://github.com/ipfs/kubo.git
synced 2025-09-10 09:52:20 +08:00
Correct pinning for dagmodifier, and a bunch more tests
This commit is contained in:
15
pin/pin.go
15
pin/pin.go
@ -47,6 +47,7 @@ type Pinner interface {
|
||||
// may not be successful
|
||||
type ManualPinner interface {
|
||||
PinWithMode(util.Key, PinMode)
|
||||
RemovePinWithMode(util.Key, PinMode)
|
||||
Pinner
|
||||
}
|
||||
|
||||
@ -198,6 +199,20 @@ func (p *pinner) IsPinned(key util.Key) bool {
|
||||
p.indirPin.HasKey(key)
|
||||
}
|
||||
|
||||
func (p *pinner) RemovePinWithMode(key util.Key, mode PinMode) {
|
||||
switch mode {
|
||||
case Direct:
|
||||
p.directPin.RemoveBlock(key)
|
||||
case Indirect:
|
||||
p.indirPin.Decrement(key)
|
||||
case Recursive:
|
||||
p.recursePin.RemoveBlock(key)
|
||||
default:
|
||||
// programmer error, panic OK
|
||||
panic("unrecognized pin type")
|
||||
}
|
||||
}
|
||||
|
||||
// LoadPinner loads a pinner and its keysets from the given datastore
|
||||
func LoadPinner(d ds.ThreadSafeDatastore, dserv mdag.DAGService) (Pinner, error) {
|
||||
p := new(pinner)
|
||||
|
Reference in New Issue
Block a user