fix: prevent crash during h2 cleanup if parent folder is null

This commit is contained in:
Gauthier Roebroeck 2021-03-16 17:37:23 +08:00
parent 4ecf20c062
commit bd20ff67cc

View file

@ -22,14 +22,18 @@ class DatabaseMigration(
@ExperimentalPathApi
@PostConstruct
fun init() {
convertHomeDir(komgaProperties.database.file).parent.listDirectoryEntries("*.mv.db*").let { h2Files ->
if (h2Files.isNotEmpty()) {
logger.info { "Deleting old H2 database files" }
h2Files.forEach {
logger.info { "Delete: $it" }
it.deleteIfExists()
try {
convertHomeDir(komgaProperties.database.file).parent?.listDirectoryEntries("*.mv.db*")?.let { h2Files ->
if (h2Files.isNotEmpty()) {
logger.info { "Deleting old H2 database files" }
h2Files.forEach {
logger.info { "Delete: $it" }
it.deleteIfExists()
}
}
}
} catch (e: Exception) {
logger.warn(e) { "Could not delete old H2 database files" }
}
}
}