From 0d0be37904ec4d38b9b8cba96c6b3d335f853c32 Mon Sep 17 00:00:00 2001 From: Roman Volosovskyi Date: Tue, 1 May 2018 16:49:16 +0200 Subject: [PATCH] [#3987] disable logging on status-go side if file is not writable --- .../java/im/status/ethereum/module/StatusModule.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 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 6e852e360c..b717f4359a 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 @@ -122,11 +122,15 @@ class StatusModule extends ReactContextBaseJavaModule implements LifecycleEventL try { logFile.setReadable(true); File parent = logFile.getParentFile(); + if (!parent.canWrite()) { + return null; + } if (!parent.exists()) { parent.mkdirs(); } logFile.createNewFile(); - logFile.setReadable(true); + logFile.setWritable(true); + Log.d(TAG, "Can write " + logFile.canWrite()); Uri gethLogUri = Uri.fromFile(logFile); try { Log.d(TAG, "Attach to geth.log to instabug " + gethLogUri.getPath()); @@ -136,7 +140,7 @@ class StatusModule extends ReactContextBaseJavaModule implements LifecycleEventL } String gethLogFilePath = logFile.getAbsolutePath(); - Log.d("ExtDirLog", gethLogFilePath); + Log.d(TAG, gethLogFilePath); return gethLogFilePath; } catch (Exception e) { @@ -215,7 +219,7 @@ class StatusModule extends ReactContextBaseJavaModule implements LifecycleEventL String gethLogFilePath = prepareLogsFile(); boolean logsEnabled = (gethLogFilePath != null) && !TextUtils.isEmpty(this.logLevel); String dataDir = root + customConfig.get("DataDir"); - jsonConfig.put("LogEnabled", logsEnabled); + jsonConfig.put("LogEnabled", (gethLogFilePath != null && logsEnabled)); jsonConfig.put("LogFile", gethLogFilePath); jsonConfig.put("LogLevel", TextUtils.isEmpty(this.logLevel) ? "ERROR" : this.logLevel.toUpperCase()); jsonConfig.put("DataDir", dataDir);