@@ -32,8 +32,9 @@ internal PinApi(IpfsClient ipfs)
3232 /// <summary>
3333 /// Adds an IPFS object to the pinset and also stores it to the IPFS repo. pinset is the set of hashes currently pinned (not gc'able).
3434 /// </summary>
35- /// <param name="hash">
36- /// The <see cref="string"/> representation of a base58 encoded <see cref="Ipfs.MultiHash"/>.
35+ /// <param name="path">
36+ /// A path to an existing object, such as "QmXarR6rgkQ2fDSHjSY5nM2kuCXKYGViky5nohtwgF65Ec/about"
37+ /// or "QmZTR5bcpQD7cFgTorqxZDYaew1Wqgfbd2ud9QqGPAkK2V"
3738 /// </param>
3839 /// <param name="recursive">
3940 /// <b>true</b> to recursively pin links of object; otherwise, <b>false</b> to only pin
@@ -42,15 +43,33 @@ internal PinApi(IpfsClient ipfs)
4243 /// <param name="cancel">
4344 /// Is used to stop the task. When cancelled, the <see cref="TaskCanceledException"/> is raised.
4445 /// </param>
45- public async Task < PinnedObject [ ] > AddAsync ( string hash , bool recursive = true , CancellationToken cancel = default ( CancellationToken ) )
46+ public async Task < PinnedObject [ ] > AddAsync ( string path , bool recursive = true , CancellationToken cancel = default ( CancellationToken ) )
4647 {
4748 var opts = "recursive=" + recursive . ToString ( ) . ToLowerInvariant ( ) ;
48- var json = await ipfs . DoCommandAsync ( "pin/add" , cancel , hash , opts ) ;
49+ var json = await ipfs . DoCommandAsync ( "pin/add" , cancel , path , opts ) ;
4950 return ( ( JArray ) JObject . Parse ( json ) [ "Pins" ] )
5051 . Select ( p => new PinnedObject { Id = ( string ) p } )
5152 . ToArray ( ) ;
5253 }
5354
55+ /// <summary>
56+ /// Adds an IPFS object to the pinset and also stores it to the IPFS repo. pinset is the set of hashes currently pinned (not gc'able).
57+ /// </summary>
58+ /// <param name="hash">
59+ /// A <see cref="MultiHash"/> id to an existing object.
60+ /// </param>
61+ /// <param name="recursive">
62+ /// <b>true</b> to recursively pin links of object; otherwise, <b>false</b> to only pin
63+ /// the specified object. Default is <b>true</b>.
64+ /// </param>
65+ /// <param name="cancel">
66+ /// Is used to stop the task. When cancelled, the <see cref="TaskCanceledException"/> is raised.
67+ /// </param>
68+ public Task < PinnedObject [ ] > AddAsync ( MultiHash hash , bool recursive = true , CancellationToken cancel = default ( CancellationToken ) )
69+ {
70+ return AddAsync ( hash . ToBase58 ( ) , recursive , cancel ) ;
71+ }
72+
5473 /// <summary>
5574 /// List all the objects pinned to local storage.
5675 /// </summary>
@@ -79,8 +98,9 @@ internal PinApi(IpfsClient ipfs)
7998 /// <summary>
8099 /// Unpin an object.
81100 /// </summary>
82- /// <param name="hash">
83- /// The <see cref="string"/> representation of a base58 encoded <see cref="Ipfs.MultiHash"/>.
101+ /// <param name="path">
102+ /// A path to an existing object, such as "QmXarR6rgkQ2fDSHjSY5nM2kuCXKYGViky5nohtwgF65Ec/about"
103+ /// or "QmZTR5bcpQD7cFgTorqxZDYaew1Wqgfbd2ud9QqGPAkK2V"
84104 /// </param>
85105 /// <param name="recursive">
86106 /// <b>true</b> to recursively unpin links of object; otherwise, <b>false</b> to only unpin
@@ -89,14 +109,32 @@ internal PinApi(IpfsClient ipfs)
89109 /// <param name="cancel">
90110 /// Is used to stop the task. When cancelled, the <see cref="TaskCanceledException"/> is raised.
91111 /// </param>
92- public async Task < PinnedObject [ ] > RemoveAsync ( string hash , bool recursive = true , CancellationToken cancel = default ( CancellationToken ) )
112+ public async Task < PinnedObject [ ] > RemoveAsync ( string path , bool recursive = true , CancellationToken cancel = default ( CancellationToken ) )
93113 {
94114 var opts = "recursive=" + recursive . ToString ( ) . ToLowerInvariant ( ) ;
95- var json = await ipfs . DoCommandAsync ( "pin/rm" , cancel , hash , opts ) ;
115+ var json = await ipfs . DoCommandAsync ( "pin/rm" , cancel , path , opts ) ;
96116 return ( ( JArray ) JObject . Parse ( json ) [ "Pins" ] )
97117 . Select ( p => new PinnedObject { Id = ( string ) p } )
98118 . ToArray ( ) ;
99119 }
120+
121+ /// <summary>
122+ /// Unpin an object.
123+ /// </summary>
124+ /// <param name="hash">
125+ /// A <see cref="MultiHash"/> id to an existing object.
126+ /// </param>
127+ /// <param name="recursive">
128+ /// <b>true</b> to recursively unpin links of object; otherwise, <b>false</b> to only unpin
129+ /// the specified object. Default is <b>true</b>.
130+ /// </param>
131+ /// <param name="cancel">
132+ /// Is used to stop the task. When cancelled, the <see cref="TaskCanceledException"/> is raised.
133+ /// </param>
134+ public Task < PinnedObject [ ] > RemoveAsync ( MultiHash hash , bool recursive = true , CancellationToken cancel = default ( CancellationToken ) )
135+ {
136+ return RemoveAsync ( hash . ToBase58 ( ) , recursive , cancel ) ;
137+ }
100138 }
101139
102140}
0 commit comments