diff --git a/src/main/kotlin/mdnet/Migrator.kt b/src/main/kotlin/mdnet/Migrator.kt index 75b75f2..801b174 100644 --- a/src/main/kotlin/mdnet/Migrator.kt +++ b/src/main/kotlin/mdnet/Migrator.kt @@ -59,12 +59,14 @@ fun migrate(path: Path) { } } - sqlite.batchInsert(DbImage) { - h2.from(DbImage).select().forEach { data -> - item { - set(DbImage.id, data[DbImage.id]) - set(DbImage.accessed, data[DbImage.accessed]) - set(DbImage.size, data[DbImage.size]) + h2.from(DbImage).select().asIterable().chunked(1000).forEach { list -> + sqlite.batchInsert(DbImage) { + for (data in list) { + item { + set(DbImage.id, data[DbImage.id]) + set(DbImage.accessed, data[DbImage.accessed]) + set(DbImage.size, data[DbImage.size]) + } } } } diff --git a/src/main/kotlin/mdnet/cache/ImageStorage.kt b/src/main/kotlin/mdnet/cache/ImageStorage.kt index 69d2db6..40c2a30 100644 --- a/src/main/kotlin/mdnet/cache/ImageStorage.kt +++ b/src/main/kotlin/mdnet/cache/ImageStorage.kt @@ -286,12 +286,10 @@ class ImageStorage( private inner class WriterImpl(private val id: String, metadata: ImageMetadata) : Writer { val tempPath = getTempPath() - override val stream: OutputStream + override val stream: OutputStream = Files.newOutputStream(tempPath, StandardOpenOption.CREATE_NEW) val metadataSize: Int init { - stream = Files.newOutputStream(tempPath, StandardOpenOption.CREATE_NEW) - val dataOutputStream = DataOutputStream(stream) dataOutputStream.writeUTF( JACKSON.writeValueAsString(metadata) @@ -338,7 +336,7 @@ class ImageStorage( getPath(id), StandardCopyOption.ATOMIC_MOVE ) - } catch (e: FileAlreadyExistsException) { + } catch (e: IOException) { // the file already exists // so we must lost the race // delete our local copy diff --git a/src/main/kotlin/mdnet/netty/ApplicationNetty.kt b/src/main/kotlin/mdnet/netty/ApplicationNetty.kt index 686f33b..3bd9968 100644 --- a/src/main/kotlin/mdnet/netty/ApplicationNetty.kt +++ b/src/main/kotlin/mdnet/netty/ApplicationNetty.kt @@ -117,7 +117,7 @@ sealed class NettyTransport(threads: Int) { return IOUringTransport(threadsToUse) } else { LOGGER.info(IOUring.unavailabilityCause()) { - "IOUring transport not available" + "IOUring transport not available (this may be normal)" } } } @@ -128,7 +128,7 @@ sealed class NettyTransport(threads: Int) { return EpollTransport(threadsToUse) } else { LOGGER.info(Epoll.unavailabilityCause()) { - "Epoll transport not available" + "Epoll transport not available (this may be normal)" } } } diff --git a/src/main/kotlin/mdnet/server/common.kt b/src/main/kotlin/mdnet/server/common.kt index acf557d..aeae7fd 100644 --- a/src/main/kotlin/mdnet/server/common.kt +++ b/src/main/kotlin/mdnet/server/common.kt @@ -51,7 +51,8 @@ fun catchAllHideDetails(): Filter { try { next(request) } catch (e: Exception) { - LOGGER.warn(e) { "Request error detected" } + val cleanedUri = request.uri.path.replaceBefore("/data", "/{token}") + LOGGER.warn(e) { "Request for $cleanedUri errored" } Response(Status.INTERNAL_SERVER_ERROR) }