@@ -21,6 +21,10 @@ function invalidPinTypeErr (type) {
21
21
return errCode ( new Error ( errMsg ) , 'ERR_INVALID_PIN_TYPE' )
22
22
}
23
23
24
+ function toKey ( cid ) {
25
+ return '/' + bs58 . encode ( cid . multihash )
26
+ }
27
+
24
28
const PinTypes = {
25
29
direct : 'direct' ,
26
30
recursive : 'recursive' ,
@@ -56,7 +60,7 @@ class PinManager {
56
60
async pinDirectly ( cid , options = { } ) {
57
61
await this . dag . get ( cid , options )
58
62
59
- return this . repo . pins . put ( bs58 . encode ( cid . multihash ) , cbor . encode ( {
63
+ return this . repo . pins . put ( toKey ( cid ) , cbor . encode ( {
60
64
cid : cid . buffer ,
61
65
type : PinTypes . direct ,
62
66
name : options . name
@@ -83,13 +87,13 @@ class PinManager {
83
87
cid = new CID ( cbor . decode ( result . value ) . cid )
84
88
}
85
89
86
- return this . repo . pins . delete ( bs58 . encode ( cid . multihash ) )
90
+ return this . repo . pins . delete ( toKey ( cid ) )
87
91
}
88
92
89
93
async pinRecursively ( cid , options = { } ) {
90
94
await this . fetchCompleteDag ( cid , options )
91
95
92
- await this . repo . pins . put ( bs58 . encode ( cid . multihash ) , cbor . encode ( {
96
+ await this . repo . pins . put ( toKey ( cid ) , cbor . encode ( {
93
97
cid : cid . buffer ,
94
98
type : PinTypes . recursive ,
95
99
name : options . name
@@ -161,7 +165,7 @@ class PinManager {
161
165
162
166
if ( recursive || direct || all ) {
163
167
const result = await first ( this . repo . pins . query ( {
164
- prefix : bs58 . encode ( cid . multihash ) ,
168
+ prefix : toKey ( cid ) ,
165
169
filters : [ entry => {
166
170
const pin = cbor . decode ( entry . value )
167
171
0 commit comments