Fixed exclude file being null not handled

This commit is contained in:
Abdelilah El Aissaoui 2023-07-15 13:56:02 +02:00
parent 1cf1eca45f
commit e7a557c305

View File

@ -29,20 +29,22 @@ class GetIgnoreRulesUseCase @Inject constructor() {
}
if (baseConfig != null) {
var excludesFilePath = baseConfig.getString("core", null, "excludesFile")
var excludesFilePath = baseConfig.getString("core", null, "excludesFile") ?: ""
if (excludesFilePath.startsWith("~")) {
excludesFilePath = excludesFilePath.replace("~", System.getProperty("user.home").orEmpty())
}
if (excludesFilePath.isNotEmpty()) {
if (excludesFilePath.startsWith("~")) {
excludesFilePath = excludesFilePath.replace("~", System.getProperty("user.home").orEmpty())
}
val excludesFile = FileSystems
.getDefault()
.getPath(excludesFilePath)
.normalize()
.toFile()
val excludesFile = FileSystems
.getDefault()
.getPath(excludesFilePath)
.normalize()
.toFile()
if (excludesFile.exists() && excludesFile.isFile) {
ignoreLines.addAll(excludesFile.readLines())
if (excludesFile.exists() && excludesFile.isFile) {
ignoreLines.addAll(excludesFile.readLines())
}
}
}