diff --git a/app/src/main/java/io/legado/app/help/storage/WebDavHelp.kt b/app/src/main/java/io/legado/app/help/storage/WebDavHelp.kt index 5576e9c11..b48a0b646 100644 --- a/app/src/main/java/io/legado/app/help/storage/WebDavHelp.kt +++ b/app/src/main/java/io/legado/app/help/storage/WebDavHelp.kt @@ -45,12 +45,16 @@ object WebDavHelp { val url = getWebDavUrl() val names = arrayListOf() if (!url.isNullOrBlank() && initWebDav()) { - var files = WebDav(url + "legado/").listFiles() - files = files.reversed() - for (index: Int in 0 until min(10, files.size)) { - files[index].displayName?.let { - names.add(it) + try { + var files = WebDav(url + "legado/").listFiles() + files = files.reversed() + for (index: Int in 0 until min(10, files.size)) { + files[index].displayName?.let { + names.add(it) + } } + } catch (e: Exception) { + return names } } return names