File tree Expand file tree Collapse file tree 3 files changed +21
-3
lines changed Expand file tree Collapse file tree 3 files changed +21
-3
lines changed Original file line number Diff line number Diff line change @@ -48,9 +48,10 @@ internal ConfigApi(IpfsClient ipfs)
4848 return ;
4949 }
5050
51- public Task ReplaceAsync ( JObject config )
51+ public async Task ReplaceAsync ( JObject config )
5252 {
53- throw new NotImplementedException ( ) ;
53+ var data = Encoding . UTF8 . GetBytes ( config . ToString ( Formatting . None ) ) ;
54+ await ipfs . UploadAsync ( "config/replace" , CancellationToken . None , data ) ;
5455 }
5556 }
5657
Original file line number Diff line number Diff line change 2727 </PropertyGroup >
2828
2929 <ItemGroup >
30- <PackageReference Include =" Ipfs.Core" Version =" 0.34.0 " />
30+ <PackageReference Include =" Ipfs.Core" Version =" 0.34.1 " />
3131 <PackageReference Include =" Newtonsoft.Json" Version =" 11.0.2" />
3232 <PackageReference Include =" System.Net.Http" Version =" 4.3.3" Condition =" '$(TargetFramework)' == 'netstandard14'" />
3333 <PackageReference Include =" System.Net.Http" Version =" 4.3.3" Condition =" '$(TargetFramework)' == 'net45'" />
Original file line number Diff line number Diff line change 33using Newtonsoft . Json . Linq ;
44using System ;
55using System . Text ;
6+ using System . Threading . Tasks ;
67
78namespace Ipfs . Api
89{
@@ -68,5 +69,21 @@ public void Set_JSON_Value()
6869 Assert . AreEqual ( "http://example.io" , ipfs . Config . GetAsync ( key ) . Result [ 0 ] ) ;
6970 }
7071
72+ [ TestMethod ]
73+ public async Task Replace_Entire_Config ( )
74+ {
75+ IpfsClient ipfs = TestFixture . Ipfs ;
76+ var original = await ipfs . Config . GetAsync ( ) ;
77+ try
78+ {
79+ var a = JObject . Parse ( "{ \" foo-x-bar\" : 1 }" ) ;
80+ await ipfs . Config . ReplaceAsync ( a ) ;
81+ }
82+ finally
83+ {
84+ await ipfs . Config . ReplaceAsync ( original ) ;
85+ }
86+ }
87+
7188 }
7289}
You can’t perform that action at this time.
0 commit comments