Just in case, clean up any existing plain file when core starts if VFS is enabled
This commit is contained in:
parent
fc6792687c
commit
1522d3b17d
2 changed files with 25 additions and 0 deletions
|
@ -317,6 +317,10 @@ class CoreContext(val context: Context, coreConfig: Config) {
|
||||||
EmojiCompat.init(BundledEmojiCompatConfig(context))
|
EmojiCompat.init(BundledEmojiCompatConfig(context))
|
||||||
collator.strength = Collator.NO_DECOMPOSITION
|
collator.strength = Collator.NO_DECOMPOSITION
|
||||||
|
|
||||||
|
if (corePreferences.vfsEnabled) {
|
||||||
|
FileUtils.clearExistingPlainFiles()
|
||||||
|
}
|
||||||
|
|
||||||
Log.i("[Context] Started")
|
Log.i("[Context] Started")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -99,6 +99,27 @@ class FileUtils {
|
||||||
return type?.startsWith("audio/") ?: false
|
return type?.startsWith("audio/") ?: false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun clearExistingPlainFiles() {
|
||||||
|
for (file in coreContext.context.filesDir.listFiles().orEmpty()) {
|
||||||
|
if (file.path.endsWith(VFS_PLAIN_FILE_EXTENSION)) {
|
||||||
|
Log.w("[File Utils] Found forgotten plain file: ${file.path}, deleting it")
|
||||||
|
deleteFile(file.path)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (file in coreContext.context.getExternalFilesDir(Environment.DIRECTORY_PICTURES)?.listFiles().orEmpty()) {
|
||||||
|
if (file.path.endsWith(VFS_PLAIN_FILE_EXTENSION)) {
|
||||||
|
Log.w("[File Utils] Found forgotten plain file: ${file.path}, deleting it")
|
||||||
|
deleteFile(file.path)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (file in coreContext.context.getExternalFilesDir(Environment.DIRECTORY_DOWNLOADS)?.listFiles().orEmpty()) {
|
||||||
|
if (file.path.endsWith(VFS_PLAIN_FILE_EXTENSION)) {
|
||||||
|
Log.w("[File Utils] Found forgotten plain file: ${file.path}, deleting it")
|
||||||
|
deleteFile(file.path)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fun getFileStorageDir(isPicture: Boolean = false): File {
|
fun getFileStorageDir(isPicture: Boolean = false): File {
|
||||||
var path: File? = null
|
var path: File? = null
|
||||||
if (Environment.getExternalStorageState() == Environment.MEDIA_MOUNTED) {
|
if (Environment.getExternalStorageState() == Environment.MEDIA_MOUNTED) {
|
||||||
|
|
Loading…
Reference in a new issue