1
0
Fork 0
mirror of https://github.com/syncthing/syncthing-android.git synced 2025-01-09 19:53:33 +00:00

Add Constants#FILENAME_STIGNORE

This commit is contained in:
Catfriend1 2019-03-10 12:26:45 +01:00
parent 18fd867af6
commit af1b93b114
2 changed files with 8 additions and 7 deletions

View file

@ -13,6 +13,7 @@ public class Constants {
public static final Boolean ENABLE_TEST_DATA = false; public static final Boolean ENABLE_TEST_DATA = false;
public static final String FILENAME_SYNCTHING_BINARY = "libsyncthing.so"; public static final String FILENAME_SYNCTHING_BINARY = "libsyncthing.so";
public static final String FILENAME_STIGNORE = ".stignore";
// Preferences - Run conditions // Preferences - Run conditions
public static final String PREF_START_SERVICE_ON_BOOT = "always_run_in_background"; public static final String PREF_START_SERVICE_ON_BOOT = "always_run_in_background";

View file

@ -646,7 +646,7 @@ public class ConfigXml {
File file; File file;
FileInputStream fileInputStream = null; FileInputStream fileInputStream = null;
try { try {
file = new File(folder.path, ".stignore"); file = new File(folder.path, Constants.FILENAME_STIGNORE);
if (file.exists()) { if (file.exists()) {
fileInputStream = new FileInputStream(file); fileInputStream = new FileInputStream(file);
InputStreamReader inputStreamReader = new InputStreamReader(fileInputStream, "UTF-8"); InputStreamReader inputStreamReader = new InputStreamReader(fileInputStream, "UTF-8");
@ -662,14 +662,14 @@ public class ConfigXml {
*/ */
} }
} catch (IOException e) { } 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 { } finally {
try { try {
if (fileInputStream != null) { if (fileInputStream != null) {
fileInputStream.close(); fileInputStream.close();
} }
} catch (IOException e) { } 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); listener.onResult(folderIgnoreList);
@ -682,12 +682,12 @@ public class ConfigXml {
File file; File file;
FileOutputStream fileOutputStream = null; FileOutputStream fileOutputStream = null;
try { try {
file = new File(folder.path, ".stignore"); file = new File(folder.path, Constants.FILENAME_STIGNORE);
if (!file.exists()) { if (!file.exists()) {
file.createNewFile(); file.createNewFile();
} }
fileOutputStream = new FileOutputStream(file); 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.write(TextUtils.join("\n", ignore).getBytes("UTF-8"));
fileOutputStream.flush(); fileOutputStream.flush();
} catch (IOException e) { } catch (IOException e) {
@ -695,14 +695,14 @@ public class ConfigXml {
* This will happen on external storage folders which exist outside the * This will happen on external storage folders which exist outside the
* "/Android/data/[package_name]/files" folder on Android 5+. * "/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 { } finally {
try { try {
if (fileOutputStream != null) { if (fileOutputStream != null) {
fileOutputStream.close(); fileOutputStream.close();
} }
} catch (IOException e) { } 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);
} }
} }
} }