mirror of
https://github.com/Helium314/HeliBoard.git
synced 2025-06-09 16:17:44 +00:00
fix broken file handling in DictionaryGroup
This commit is contained in:
parent
e25300d832
commit
7bc74810b1
1 changed files with 2 additions and 1 deletions
|
@ -718,7 +718,7 @@ private class DictionaryGroup(
|
||||||
// words cannot be (permanently) removed from some dictionaries, so we use a blacklist for "removing" words
|
// words cannot be (permanently) removed from some dictionaries, so we use a blacklist for "removing" words
|
||||||
private val blacklistFile = context?.let {
|
private val blacklistFile = context?.let {
|
||||||
File(it.filesDir.absolutePath + File.separator + "blacklists" + File.separator + locale.toLanguageTag() + ".txt")
|
File(it.filesDir.absolutePath + File.separator + "blacklists" + File.separator + locale.toLanguageTag() + ".txt")
|
||||||
.also { it.mkdirs() }
|
.also { it.parentFile?.mkdirs() }
|
||||||
}
|
}
|
||||||
|
|
||||||
private val blacklist = hashSetOf<String>().apply {
|
private val blacklist = hashSetOf<String>().apply {
|
||||||
|
@ -741,6 +741,7 @@ private class DictionaryGroup(
|
||||||
scope.launch {
|
scope.launch {
|
||||||
synchronized(this) {
|
synchronized(this) {
|
||||||
try {
|
try {
|
||||||
|
if (blacklistFile.isDirectory) blacklistFile.delete()
|
||||||
blacklistFile.appendText("$word\n")
|
blacklistFile.appendText("$word\n")
|
||||||
} catch (e: IOException) {
|
} catch (e: IOException) {
|
||||||
Log.e(TAG, "Exception while trying to add word \"$word\" to blacklist ${blacklistFile.name}", e)
|
Log.e(TAG, "Exception while trying to add word \"$word\" to blacklist ${blacklistFile.name}", e)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue