2121import fulamobile .Config ;
2222import fulamobile .Fulamobile ;
2323
24- import land .fx .wnfslib .LibKt ;
24+ import land .fx .wnfslib .Fs ;
2525
2626@ ReactModule (name = FulaModule .NAME )
2727public class FulaModule extends ReactContextBaseJavaModule {
@@ -35,9 +35,9 @@ public class FulaModule extends ReactContextBaseJavaModule {
3535 SharedPreferenceHelper sharedPref ;
3636 static String PRIVATE_KEY_STORE_ID = "PRIVATE_KEY" ;
3737
38- public class Client implements land .fx .wnfslib .Client {
38+ public class Client implements land .fx .wnfslib .Datastore {
3939
40- private fulamobile .Client internalClient ;
40+ private final fulamobile .Client internalClient ;
4141
4242 Client (fulamobile .Client clientInput ) {
4343 internalClient = clientInput ;
@@ -51,7 +51,7 @@ public byte[] get(@NonNull byte[] cid) {
5151 } catch (Exception e ) {
5252 e .printStackTrace ();
5353 }
54- return null ;
54+ return cid ;
5555 }
5656
5757 @ NonNull
@@ -62,7 +62,7 @@ public byte[] put(@NonNull byte[] data, long codec) {
6262 } catch (Exception e ) {
6363 e .printStackTrace ();
6464 }
65- return null ;
65+ return data ;
6666 }
6767 }
6868
@@ -85,7 +85,7 @@ public FulaModule(ReactApplicationContext reactContext) {
8585
8686 @ Override
8787 @ NonNull
88- public String getName () {
88+ public java . lang . String getName () {
8989 return NAME ;
9090 }
9191
@@ -192,9 +192,10 @@ private String[] initInternal(byte[] identity, String storePath, String bloxAddr
192192 Log .d ("ReactNative" , "fula initialized: " + this .fula .id ());
193193 if (this .rootConfig == null ) {
194194 Log .d ("ReactNative" , "creating rootConfig" );
195- this .privateForest = LibKt .createPrivateForest (this .client );
195+
196+ this .privateForest = Fs .createPrivateForest (this .client );
196197 Log .d ("ReactNative" , "privateForest is created: " + this .privateForest );
197- this .rootConfig = LibKt .createRootDir (this .client , this .privateForest );
198+ this .rootConfig = Fs .createRootDir (this .client , this .privateForest );
198199 Log .d ("ReactNative" , "rootConfig is created: " + this .rootConfig .getCid ());
199200 } else {
200201 Log .d ("ReactNative" , "rootConfig existed: " + this .rootConfig .getCid ());
@@ -217,7 +218,7 @@ public void mkdir(String path, Promise promise) {
217218 ThreadUtils .runOnExecutor (() -> {
218219 Log .d ("ReactNative" , "mkdir: path = " + path );
219220 try {
220- land .fx .wnfslib .Config config = LibKt .mkdir (this .client , this .rootConfig .getCid (), this .rootConfig .getPrivate_ref (), path );
221+ land .fx .wnfslib .Config config = Fs .mkdir (this .client , this .rootConfig .getCid (), this .rootConfig .getPrivate_ref (), path );
221222 this .rootConfig = config ;
222223 promise .resolve (config .getCid ());
223224 } catch (Exception e ) {
@@ -239,7 +240,7 @@ public void writeFile(String fulaTargetFilename, String localFilename, Promise p
239240 ThreadUtils .runOnExecutor (() -> {
240241 Log .d ("ReactNative" , "writeFile to : path = " + fulaTargetFilename + ", from: " + localFilename );
241242 try {
242- land .fx .wnfslib .Config config = LibKt .writeFileFromPath (this .client , this .rootConfig .getCid (), this .rootConfig .getPrivate_ref (), fulaTargetFilename , localFilename );
243+ land .fx .wnfslib .Config config = Fs .writeFileFromPath (this .client , this .rootConfig .getCid (), this .rootConfig .getPrivate_ref (), fulaTargetFilename , localFilename );
243244 this .rootConfig = config ;
244245 promise .resolve (config .getCid ());
245246 } catch (Exception e ) {
@@ -256,7 +257,7 @@ public void writeFileContent(String path, String contentString, Promise promise)
256257 Log .d ("ReactNative" , "writeFile: path = " + path );
257258 try {
258259 byte [] content = convertStringToByte (contentString );
259- land .fx .wnfslib .Config config = LibKt .writeFile (this .client , this .rootConfig .getCid (), this .rootConfig .getPrivate_ref (), path , content );
260+ land .fx .wnfslib .Config config = Fs .writeFile (this .client , this .rootConfig .getCid (), this .rootConfig .getPrivate_ref (), path , content );
260261 this .rootConfig = config ;
261262 promise .resolve (config .getCid ());
262263 } catch (Exception e ) {
@@ -271,7 +272,7 @@ public void ls(String path, Promise promise) {
271272 ThreadUtils .runOnExecutor (() -> {
272273 Log .d ("ReactNative" , "ls: path = " + path );
273274 try {
274- String res = LibKt .ls (this .client , this .rootConfig .getCid (), this .rootConfig .getPrivate_ref (), path );
275+ String res = Fs .ls (this .client , this .rootConfig .getCid (), this .rootConfig .getPrivate_ref (), path );
275276 promise .resolve (res );
276277 } catch (Exception e ) {
277278 Log .d ("get" , e .getMessage ());
@@ -285,7 +286,7 @@ public void rm(String path, Promise promise) {
285286 ThreadUtils .runOnExecutor (() -> {
286287 Log .d ("ReactNative" , "rm: path = " + path );
287288 try {
288- land .fx .wnfslib .Config config = LibKt .rm (this .client , this .rootConfig .getCid (), this .rootConfig .getPrivate_ref (), path );
289+ land .fx .wnfslib .Config config = Fs .rm (this .client , this .rootConfig .getCid (), this .rootConfig .getPrivate_ref (), path );
289290 this .rootConfig = config ;
290291 promise .resolve (config .getCid ());
291292 } catch (Exception e ) {
@@ -307,7 +308,7 @@ public void readFile(String fulaTargetFilename, String localFilename, Promise pr
307308 ThreadUtils .runOnExecutor (() -> {
308309 Log .d ("ReactNative" , "readFile: fulaTargetFilename = " + fulaTargetFilename );
309310 try {
310- String path = LibKt .readFileToPath (this .client , this .rootConfig .getCid (), this .rootConfig .getPrivate_ref (), fulaTargetFilename , localFilename );
311+ String path = Fs .readFileToPath (this .client , this .rootConfig .getCid (), this .rootConfig .getPrivate_ref (), fulaTargetFilename , localFilename );
311312 promise .resolve (path );
312313 } catch (Exception e ) {
313314 Log .d ("get" , e .getMessage ());
@@ -321,7 +322,7 @@ public void readFileContent(String path, Promise promise) {
321322 ThreadUtils .runOnExecutor (() -> {
322323 Log .d ("ReactNative" , "readFileContent: path = " + path );
323324 try {
324- byte [] res = LibKt .readFile (this .client , this .rootConfig .getCid (), this .rootConfig .getPrivate_ref (), path );
325+ byte [] res = Fs .readFile (this .client , this .rootConfig .getCid (), this .rootConfig .getPrivate_ref (), path );
325326 String resString = toString (res );
326327 promise .resolve (resString );
327328 } catch (Exception e ) {
@@ -377,7 +378,6 @@ public void has(String keyString, Promise promise) {
377378 });
378379 }
379380
380- @ NonNull
381381 private boolean hasInternal (byte [] key ) throws Exception {
382382 try {
383383 boolean res = this .fula .has (key );
@@ -388,7 +388,6 @@ private boolean hasInternal(byte[] key) throws Exception {
388388 }
389389 }
390390
391- @ NonNull
392391 private void pullInternal (byte [] key ) throws Exception {
393392 try {
394393 this .fula .pull (key );
@@ -412,7 +411,6 @@ public void push(Promise promise) {
412411 });
413412 }
414413
415- @ NonNull
416414 private void pushInternal (byte [] key ) throws Exception {
417415 try {
418416 if (this .fula .has (key )) {
0 commit comments