From af1b93b11439a01dffbd16b8af65077c8973b558 Mon Sep 17 00:00:00 2001 From: Catfriend1 Date: Sun, 10 Mar 2019 12:26:45 +0100 Subject: [PATCH] Add Constants#FILENAME_STIGNORE --- .../syncthingandroid/service/Constants.java | 1 + .../nutomic/syncthingandroid/util/ConfigXml.java | 14 +++++++------- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/com/nutomic/syncthingandroid/service/Constants.java b/app/src/main/java/com/nutomic/syncthingandroid/service/Constants.java index cad177b4..ee3c403a 100644 --- a/app/src/main/java/com/nutomic/syncthingandroid/service/Constants.java +++ b/app/src/main/java/com/nutomic/syncthingandroid/service/Constants.java @@ -13,6 +13,7 @@ public class Constants { public static final Boolean ENABLE_TEST_DATA = false; public static final String FILENAME_SYNCTHING_BINARY = "libsyncthing.so"; + public static final String FILENAME_STIGNORE = ".stignore"; // Preferences - Run conditions public static final String PREF_START_SERVICE_ON_BOOT = "always_run_in_background"; diff --git a/app/src/main/java/com/nutomic/syncthingandroid/util/ConfigXml.java b/app/src/main/java/com/nutomic/syncthingandroid/util/ConfigXml.java index 0f516e13..33c7aad6 100644 --- a/app/src/main/java/com/nutomic/syncthingandroid/util/ConfigXml.java +++ b/app/src/main/java/com/nutomic/syncthingandroid/util/ConfigXml.java @@ -646,7 +646,7 @@ public class ConfigXml { File file; FileInputStream fileInputStream = null; try { - file = new File(folder.path, ".stignore"); + file = new File(folder.path, Constants.FILENAME_STIGNORE); if (file.exists()) { fileInputStream = new FileInputStream(file); InputStreamReader inputStreamReader = new InputStreamReader(fileInputStream, "UTF-8"); @@ -662,14 +662,14 @@ public class ConfigXml { */ } } catch (IOException e) { - Log.e(TAG, "getFolderIgnoreList: Failed to read '" + folder.path + "/.stignore' #1", e); + Log.e(TAG, "getFolderIgnoreList: Failed to read '" + folder.path + "/" + Constants.FILENAME_STIGNORE + "' #1", e); } finally { try { if (fileInputStream != null) { fileInputStream.close(); } } catch (IOException e) { - Log.e(TAG, "getFolderIgnoreList: Failed to read '" + folder.path + "/.stignore' #2", e); + Log.e(TAG, "getFolderIgnoreList: Failed to read '" + folder.path + "/" + Constants.FILENAME_STIGNORE + "' #2", e); } } listener.onResult(folderIgnoreList); @@ -682,12 +682,12 @@ public class ConfigXml { File file; FileOutputStream fileOutputStream = null; try { - file = new File(folder.path, ".stignore"); + file = new File(folder.path, Constants.FILENAME_STIGNORE); if (!file.exists()) { file.createNewFile(); } fileOutputStream = new FileOutputStream(file); - // Log.v(TAG, "postFolderIgnoreList: Writing .stignore content=" + TextUtils.join("\n", ignore)); + // Log.v(TAG, "postFolderIgnoreList: Writing " + Constants.FILENAME_STIGNORE + " content=" + TextUtils.join("\n", ignore)); fileOutputStream.write(TextUtils.join("\n", ignore).getBytes("UTF-8")); fileOutputStream.flush(); } catch (IOException e) { @@ -695,14 +695,14 @@ public class ConfigXml { * This will happen on external storage folders which exist outside the * "/Android/data/[package_name]/files" folder on Android 5+. */ - Log.w(TAG, "postFolderIgnoreList: Failed to write '" + folder.path + "/.stignore' #1", e); + Log.w(TAG, "postFolderIgnoreList: Failed to write '" + folder.path + "/" + Constants.FILENAME_STIGNORE + "' #1", e); } finally { try { if (fileOutputStream != null) { fileOutputStream.close(); } } catch (IOException e) { - Log.e(TAG, "postFolderIgnoreList: Failed to write '" + folder.path + "/.stignore' #2", e); + Log.e(TAG, "postFolderIgnoreList: Failed to write '" + folder.path + "/" + Constants.FILENAME_STIGNORE + "' #2", e); } } }