From: Lanius Trolling Date: Sun, 28 Apr 2024 16:04:29 +0000 (-0400) Subject: Reduce redundancy X-Git-Url: https://gitweb.starshipfights.net/?a=commitdiff_plain;h=d2ef7bbd4b4d0b0e101917b6bca3c3b44b858a3f;p=factbooks Reduce redundancy --- diff --git a/src/jvmMain/kotlin/info/mechyrdia/route/ResourceWebDav.kt b/src/jvmMain/kotlin/info/mechyrdia/route/ResourceWebDav.kt index 67b7e1c..81f2c6a 100644 --- a/src/jvmMain/kotlin/info/mechyrdia/route/ResourceWebDav.kt +++ b/src/jvmMain/kotlin/info/mechyrdia/route/ResourceWebDav.kt @@ -94,10 +94,13 @@ private suspend fun getWebDavPropertiesWithIncludeTags(path: StoragePath, webRoo ) to (depth >= 0) ) } ?: FileStorage.instance.listDir(path)?.let { subEntries -> - val subPaths = subEntries.keys.map { path / it } - val subProps = subPaths.mapSuspend { subPath -> - getWebDavPropertiesWithIncludeTags(subPath, webRoot, depth - 1) - }.filterNotNull().flatten() + val subProps = subEntries.keys + .map { path / it } + .mapSuspend { subPath -> + getWebDavPropertiesWithIncludeTags(subPath, webRoot, depth - 1) + } + .filterNotNull() + .flatten() val pathWithSuffix = path.elements.joinToString(separator = "") { "$it/" } listOf( @@ -119,12 +122,13 @@ suspend fun getWebDavProperties(path: StoragePath, webRoot: String, depth: Int = suspend fun FileStorage.copyWebDav(source: StoragePath, target: StoragePath): Boolean { return when (getType(source)) { - StoredFileType.DIRECTORY -> createDir(target) && (listDir(source)?.let { subPaths -> - val copyActions = subPaths.keys.map { (source / it) to (target / it) } - copyActions.mapSuspend { (subSource, subTarget) -> + StoredFileType.DIRECTORY -> createDir(target) && (listDir(source) + ?.keys + ?.map { (source / it) to (target / it) } + ?.mapSuspend { (subSource, subTarget) -> copyWebDav(subSource, subTarget) - }.all { it } - } == true) + } + ?.all { it } == true) StoredFileType.FILE -> copyFile(source, target)