From 52d9b0b8634ac2c84327d9fccbe1423646b2d119 Mon Sep 17 00:00:00 2001 From: ehsan shariati Date: Thu, 3 Aug 2023 17:13:26 -0400 Subject: [PATCH] added more logging around rootCid --- .../main/java/land/fx/fula/FulaModule.java | 20 ++++++++++++------- package.json | 2 +- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/android/src/main/java/land/fx/fula/FulaModule.java b/android/src/main/java/land/fx/fula/FulaModule.java index 8ead355..eb5a968 100755 --- a/android/src/main/java/land/fx/fula/FulaModule.java +++ b/android/src/main/java/land/fx/fula/FulaModule.java @@ -712,7 +712,7 @@ private String[] initInternal(byte[] identity, String storePath, String bloxAddr this.createNewRootConfig(this.client, identity); } } else { - Log.d("ReactNative", "Recovered cid and private ref from keychain store. cid="+cid); + Log.d("ReactNative", "Recovered cid and private ref from keychain store. cid="+cid +" and cid from input was: "+rootCid); this.rootConfig = new land.fx.wnfslib.Config(cid); this.reloadFS(this.client, identity, cid); this.encrypt_and_store_config(); @@ -742,7 +742,7 @@ private String[] initInternal(byte[] identity, String storePath, String bloxAddr @ReactMethod public void mkdir(String path, Promise promise) { ThreadUtils.runOnExecutor(() -> { - Log.d("ReactNative", "mkdir: path = " + path); + Log.d("ReactNative", "mkdir started with: path = " + path + " rootConfig.getCid() = " + this.rootConfig.getCid()); try { land.fx.wnfslib.Config config = Fs.mkdir(this.client, this.rootConfig.getCid(), path); if(config != null) { @@ -751,7 +751,9 @@ public void mkdir(String path, Promise promise) { if (this.fula != null) { this.fula.flush(); } - promise.resolve(config.getCid()); + String rootCid = this.rootConfig.getCid(); + Log.d("ReactNative", "mkdir completed successfully with rootCid = " + rootCid); + promise.resolve(rootCid); } else { Log.d("ReactNative", "mkdir Error: config is null"); promise.reject(new Exception("mkdir Error: config is null")); @@ -783,7 +785,9 @@ public void writeFile(String fulaTargetFilename, String localFilename, Promise p this.encrypt_and_store_config(); if (this.fula != null) { this.fula.flush(); - promise.resolve(config.getCid()); + String rootCid = this.rootConfig.getCid(); + Log.d("ReactNative", "writeFileFromPath completed: this.rootConfig.getCid=" + rootCid); + promise.resolve(rootCid); } else { Log.d("ReactNative", "writeFile Error: fula is null"); promise.reject(new Exception("writeFile Error: fula is null")); @@ -844,7 +848,7 @@ public void ls(String path, Promise promise) { @ReactMethod public void rm(String path, Promise promise) { ThreadUtils.runOnExecutor(() -> { - Log.d("ReactNative", "rm: path = " + path); + Log.d("ReactNative", "rm: path = " + path + ", beginning rootCid=" + this.rootConfig.getCid()); try { land.fx.wnfslib.Config config = Fs.rm(this.client, this.rootConfig.getCid(), path); if(config != null) { @@ -853,7 +857,9 @@ public void rm(String path, Promise promise) { if (this.fula != null) { this.fula.flush(); } - promise.resolve(config.getCid()); + String rootCid = config.getCid(); + Log.d("ReactNative", "rm: returned rootCid = " + rootCid); + promise.resolve(rootCid); } else { Log.d("ReactNative", "rm Error: config is null"); promise.reject(new Exception("rm Error: config is null")); @@ -925,7 +931,7 @@ public void readFile(String fulaTargetFilename, String localFilename, Promise pr ThreadUtils.runOnExecutor(() -> { Log.d("ReactNative", "readFile: fulaTargetFilename = " + fulaTargetFilename); try { - Log.d("ReactNative", "readFile: localFilename = " + localFilename + " fulaTargetFilename = " + fulaTargetFilename + " cid = " + this.rootConfig.getCid() + " client = " + this.client); + Log.d("ReactNative", "readFile: localFilename = " + localFilename + " fulaTargetFilename = " + fulaTargetFilename + " beginning rootCid = " + this.rootConfig.getCid()); String path = Fs.readFilestreamToPath(this.client, this.rootConfig.getCid(), fulaTargetFilename, localFilename); promise.resolve(path); } catch (Exception e) { diff --git a/package.json b/package.json index de325cb..c0f5299 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@functionland/react-native-fula", - "version": "1.14.0", + "version": "1.14.1", "description": "This package is a bridge to use the Fula libp2p protocols in the react-native which is using wnfs", "main": "lib/commonjs/index", "module": "lib/module/index",