aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/java/org
diff options
context:
space:
mode:
Diffstat (limited to 'app/src/main/java/org')
-rw-r--r--app/src/main/java/org/pacien/tincapp/context/AppPaths.kt11
-rw-r--r--app/src/main/java/org/pacien/tincapp/context/ConfigurationDirectoryMigrator.kt4
2 files changed, 8 insertions, 7 deletions
diff --git a/app/src/main/java/org/pacien/tincapp/context/AppPaths.kt b/app/src/main/java/org/pacien/tincapp/context/AppPaths.kt
index 9aa2037..92348d6 100644
--- a/app/src/main/java/org/pacien/tincapp/context/AppPaths.kt
+++ b/app/src/main/java/org/pacien/tincapp/context/AppPaths.kt
@@ -1,6 +1,6 @@
1/* 1/*
2 * Tinc App, an Android binding and user interface for the tinc mesh VPN daemon 2 * Tinc App, an Android binding and user interface for the tinc mesh VPN daemon
3 * Copyright (C) 2017-2020 Pacien TRAN-GIRARD 3 * Copyright (C) 2017-2023 Pacien TRAN-GIRARD
4 * 4 *
5 * This program is free software: you can redistribute it and/or modify 5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by 6 * it under the terms of the GNU General Public License as published by
@@ -49,10 +49,11 @@ object AppPaths {
49 49
50 private val context by lazy { App.getContext() } 50 private val context by lazy { App.getContext() }
51 51
52 private fun cacheDir() = context.cacheDir!! 52 private fun privateCacheDir() = context.cacheDir!!
53 private fun publicCacheDir() = context.externalCacheDir!!
53 private fun binDir() = File(context.applicationInfo.nativeLibraryDir) 54 private fun binDir() = File(context.applicationInfo.nativeLibraryDir)
54 fun runtimeDir() = withDir(File(cacheDir(), APP_TINC_RUNTIME_DIR)) 55 fun runtimeDir() = withDir(File(privateCacheDir(), APP_TINC_RUNTIME_DIR))
55 fun logDir() = withDir(File(cacheDir(), APP_LOG_DIR)) 56 fun logDir() = withDir(File(publicCacheDir(), APP_LOG_DIR))
56 fun confDir() = withDir(File(context.filesDir!!, APP_TINC_NETWORKS_DIR)) 57 fun confDir() = withDir(File(context.filesDir!!, APP_TINC_NETWORKS_DIR))
57 58
58 fun confDir(netName: String) = File(confDir(), netName) 59 fun confDir(netName: String) = File(confDir(), netName)
@@ -63,7 +64,7 @@ object AppPaths {
63 fun logFile(netName: String) = File(logDir(), String.format(LOGFILE_FORMAT, netName)) 64 fun logFile(netName: String) = File(logDir(), String.format(LOGFILE_FORMAT, netName))
64 fun pidFile(netName: String) = File(runtimeDir(), String.format(PIDFILE_FORMAT, netName)) 65 fun pidFile(netName: String) = File(runtimeDir(), String.format(PIDFILE_FORMAT, netName))
65 fun appLogFile() = File(logDir(), APPLOG_FILE) 66 fun appLogFile() = File(logDir(), APPLOG_FILE)
66 fun crashFlagFile() = File(cacheDir(), CRASHFLAG_FILE) 67 fun crashFlagFile() = File(privateCacheDir(), CRASHFLAG_FILE)
67 68
68 fun existing(f: File) = f.apply { if (!exists()) throw FileNotFoundException(f.absolutePath) } 69 fun existing(f: File) = f.apply { if (!exists()) throw FileNotFoundException(f.absolutePath) }
69 fun withDir(f: File) = f.apply { if (!exists()) mkdirs() } 70 fun withDir(f: File) = f.apply { if (!exists()) mkdirs() }
diff --git a/app/src/main/java/org/pacien/tincapp/context/ConfigurationDirectoryMigrator.kt b/app/src/main/java/org/pacien/tincapp/context/ConfigurationDirectoryMigrator.kt
index 0fedf6f..ea0b7d8 100644
--- a/app/src/main/java/org/pacien/tincapp/context/ConfigurationDirectoryMigrator.kt
+++ b/app/src/main/java/org/pacien/tincapp/context/ConfigurationDirectoryMigrator.kt
@@ -1,6 +1,6 @@
1/* 1/*
2 * Tinc App, an Android binding and user interface for the tinc mesh VPN daemon 2 * Tinc App, an Android binding and user interface for the tinc mesh VPN daemon
3 * Copyright (C) 2017-2020 Pacien TRAN-GIRARD 3 * Copyright (C) 2017-2023 Pacien TRAN-GIRARD
4 * 4 *
5 * This program is free software: you can redistribute it and/or modify 5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by 6 * it under the terms of the GNU General Public License as published by
@@ -56,7 +56,7 @@ class ConfigurationDirectoryMigrator {
56 } 56 }
57 57
58 private fun migrateLogDirectory() { 58 private fun migrateLogDirectory() {
59 val oldLogDir = context.externalCacheDir 59 val oldLogDir = context.cacheDir
60 if (oldLogDir == null || oldLogDir.listFiles().isNullOrEmpty()) return // nothing to do 60 if (oldLogDir == null || oldLogDir.listFiles().isNullOrEmpty()) return // nothing to do
61 61
62 try { 62 try {