Skip to content

Commit

Permalink
added more logging around rootCid
Browse files Browse the repository at this point in the history
  • Loading branch information
ehsan6sha committed Aug 3, 2023
1 parent aec16af commit 52d9b0b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
20 changes: 13 additions & 7 deletions android/src/main/java/land/fx/fula/FulaModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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) {
Expand All @@ -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"));
Expand Down Expand Up @@ -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"));
Expand Down Expand Up @@ -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) {
Expand All @@ -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"));
Expand Down Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down

0 comments on commit 52d9b0b

Please sign in to comment.