From 23e02c1b6fb6e859ebb06c6eddd8f819ed0175b5 Mon Sep 17 00:00:00 2001 From: xis Date: Mon, 23 Oct 2023 20:04:28 +0200 Subject: [PATCH] Fix catching exception while building the content tree --- .../nextclouddlna/nextcloud/db/NextcloudDB.kt | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/main/kotlin/net/schowek/nextclouddlna/nextcloud/db/NextcloudDB.kt b/src/main/kotlin/net/schowek/nextclouddlna/nextcloud/db/NextcloudDB.kt index 8292cad..ed3c7f5 100644 --- a/src/main/kotlin/net/schowek/nextclouddlna/nextcloud/db/NextcloudDB.kt +++ b/src/main/kotlin/net/schowek/nextclouddlna/nextcloud/db/NextcloudDB.kt @@ -87,12 +87,14 @@ class NextcloudDB( children.filter { f -> f.mimetype == folderMimeType } .forEach { folder -> n.addNode(asNode(folder)) } - try { - children.filter { f -> f.mimetype != folderMimeType } - .forEach { file -> n.addItem(asItem(file)) } - } catch (e: Exception) { - logger.warn(e.message) - } + children.filter { f -> f.mimetype != folderMimeType } + .forEach { file -> + runCatching { + n.addItem(asItem(file)) + }.recover { + logger.warn(it.message) + } + } } fun maxMtime(): Long = filecacheRepository.findFirstByOrderByStorageMtimeDesc().storageMtime