From e9192835befa38e15696bcb3dc1ecf06a77f6e3d Mon Sep 17 00:00:00 2001 From: Roman Volosovskyi Date: Fri, 31 Jan 2020 14:43:32 +0200 Subject: [PATCH] [#9942] Upgradable paths in configs --- .../status/ethereum/module/StatusModule.java | 25 ++++++++++++------- .../ios/RCTStatus/RCTStatus.m | 22 +++++++++------- src/status_im/utils/platform.cljs | 5 ++-- status-go-version.json | 6 ++--- 4 files changed, 34 insertions(+), 24 deletions(-) diff --git a/modules/react-native-status/android/src/main/java/im/status/ethereum/module/StatusModule.java b/modules/react-native-status/android/src/main/java/im/status/ethereum/module/StatusModule.java index 3eb208e9f97b..a29f2a65074e 100644 --- a/modules/react-native-status/android/src/main/java/im/status/ethereum/module/StatusModule.java +++ b/modules/react-native-status/android/src/main/java/im/status/ethereum/module/StatusModule.java @@ -165,7 +165,7 @@ private File getLogsFile() { return logFile; } - private String prepareLogsFile(final Context context) { + private File prepareLogsFile(final Context context) { final File logFile = getLogsFile(); try { @@ -185,7 +185,7 @@ private String prepareLogsFile(final Context context) { String gethLogFilePath = logFile.getAbsolutePath(); Log.d(TAG, gethLogFilePath); - return gethLogFilePath; + return logFile; } catch (Exception e) { Log.d(TAG, "Can't create geth.log file! " + e.getMessage()); } @@ -193,17 +193,24 @@ private String prepareLogsFile(final Context context) { return null; } - private String updateConfig(final String jsonConfigString, final String absRootDirPath, final String absKeystoreDirPath) throws JSONException { + private String updateConfig(final String jsonConfigString, final String absRootDirPath, final String keystoreDirPath) throws JSONException { final JSONObject jsonConfig = new JSONObject(jsonConfigString); // retrieve parameters from app config, that will be applied onto the Go-side config later on - final String absDataDirPath = pathCombine(absRootDirPath, jsonConfig.getString("DataDir")); + final String dataDirPath = jsonConfig.getString("DataDir"); final Boolean logEnabled = jsonConfig.getBoolean("LogEnabled"); final Context context = this.getReactApplicationContext(); - final String gethLogFilePath = logEnabled ? prepareLogsFile(context) : null; + final File gethLogFile = logEnabled ? prepareLogsFile(context) : null; + String gethLogDirPath = null; + if (gethLogFile != null) { + gethLogDirPath = gethLogFile.getParent(); + } + + Log.d(TAG, "log dir: " + gethLogDirPath + " log name: " + gethLogFileName); - jsonConfig.put("DataDir", absDataDirPath); - jsonConfig.put("KeyStoreDir", absKeystoreDirPath); - jsonConfig.put("LogFile", gethLogFilePath); + jsonConfig.put("DataDir", dataDirPath); + jsonConfig.put("KeyStoreDir", keystoreDirPath); + jsonConfig.put("LogDir", gethLogDirPath); + jsonConfig.put("LogFile", gethLogFileName); return jsonConfig.toString(); } @@ -291,7 +298,7 @@ private String prepareDirAndUpdateConfig(final String jsonConfigString) { } try { - final String updatedJsonConfigString = this.updateConfig(jsonConfigString, absRootDirPath, newKeystoreDir); + final String updatedJsonConfigString = this.updateConfig(jsonConfigString, absRootDirPath, "/keystore"); prettyPrintConfig(updatedJsonConfigString); diff --git a/modules/react-native-status/ios/RCTStatus/RCTStatus.m b/modules/react-native-status/ios/RCTStatus/RCTStatus.m index 93f1646a5071..eabfb1705082 100644 --- a/modules/react-native-status/ios/RCTStatus/RCTStatus.m +++ b/modules/react-native-status/ios/RCTStatus/RCTStatus.m @@ -325,8 +325,9 @@ -(NSString *) prepareDirAndUpdateConfig:(NSString *)config { NSLog(@"after remove lightchaindata"); - NSURL *absTestnetKeystoreUrl = [absTestnetFolderName URLByAppendingPathComponent:@"keystore"]; - NSURL *absKeystoreUrl = [rootUrl URLByAppendingPathComponent:@"keystore"]; + NSString *keystore = @"keystore"; + NSURL *absTestnetKeystoreUrl = [absTestnetFolderName URLByAppendingPathComponent:keystore]; + NSURL *absKeystoreUrl = [rootUrl URLByAppendingPathComponent:keystore]; if([fileManager fileExistsAtPath:absTestnetKeystoreUrl.path]){ NSLog(@"copy keystore"); [fileManager copyItemAtPath:absTestnetKeystoreUrl.path toPath:absKeystoreUrl.path error:nil]; @@ -341,19 +342,22 @@ -(NSString *) prepareDirAndUpdateConfig:(NSString *)config { NSString *relativeDataDir = [configJSON objectForKey:@"DataDir"]; NSString *absDataDir = [rootUrl.path stringByAppendingString:relativeDataDir]; NSURL *absDataDirUrl = [NSURL fileURLWithPath:absDataDir]; - NSURL *absLogUrl = [absDataDirUrl URLByAppendingPathComponent:@"geth.log"]; - [configJSON setValue:absDataDirUrl.path forKey:@"DataDir"]; - [configJSON setValue:absKeystoreUrl.path forKey:@"KeyStoreDir"]; - [configJSON setValue:absLogUrl.path forKey:@"LogFile"]; + NSURL *dataDirUrl = [NSURL fileURLWithPath:relativeDataDir]; + NSURL *logUrl = [dataDirUrl URLByAppendingPathComponent:@"geth.log"]; + [configJSON setValue:@"/keystore" forKey:@"KeyStoreDir"]; + [configJSON setValue:@"" forKey:@"LogDir"]; + [configJSON setValue:logUrl.path forKey:@"LogFile"]; NSString *resultingConfig = [configJSON bv_jsonStringWithPrettyPrint:NO]; NSLog(@"node config %@", resultingConfig); - if(![fileManager fileExistsAtPath:absDataDirUrl.path]) { - [fileManager createDirectoryAtPath:absDataDirUrl.path withIntermediateDirectories:YES attributes:nil error:nil]; + if(![fileManager fileExistsAtPath:absDataDir]) { + [fileManager createDirectoryAtPath:absDataDir + withIntermediateDirectories:YES attributes:nil error:nil]; } - NSLog(@"logUrlPath %@", absLogUrl.path); + NSLog(@"logUrlPath %@ rootDir %@", logUrl.path, rootUrl.path); + NSURL *absLogUrl = [absDataDirUrl URLByAppendingPathComponent:@"geth.log"]; if(![fileManager fileExistsAtPath:absLogUrl.path]) { NSMutableDictionary *dict = [[NSMutableDictionary alloc] init]; [dict setObject:[NSNumber numberWithInt:511] forKey:NSFilePosixPermissions]; diff --git a/src/status_im/utils/platform.cljs b/src/status_im/utils/platform.cljs index 5cc3f167d535..cbc9274404d9 100644 --- a/src/status_im/utils/platform.cljs +++ b/src/status_im/utils/platform.cljs @@ -33,9 +33,8 @@ (defn no-backup-directory [] (cond - android? (str (.-DocumentDirectoryPath rn-dependencies/fs) - "/../no_backup") - ios? (.-LibraryDirectoryPath rn-dependencies/fs))) + android? "/../no_backup" + ios? "/")) (defn android-version>= [v] (and android? (>= version v))) diff --git a/status-go-version.json b/status-go-version.json index b7beeea583bb..a6096a551de7 100644 --- a/status-go-version.json +++ b/status-go-version.json @@ -2,7 +2,7 @@ "_comment": "DO NOT EDIT THIS FILE BY HAND. USE 'scripts/update-status-go.sh ' instead", "owner": "status-im", "repo": "status-go", - "version": "v0.41.1", - "commit-sha1": "c2f22f1fbc73e68b8d82370c4645c786739fb40b", - "src-sha256": "038paj2gwdih154nnafcxc3w02x9p21ifkv1g9k2rr1ac0ypainb" + "version": "relative-paths", + "commit-sha1": "992168b11451821a5a7115279e8f06a997b07421", + "src-sha256": "13i05il27h4x7c956314q5hv84ww983s4hvrv4m217f5a0bgbrzg" }