Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@ package dev.typetype.server.services

import io.ktor.utils.io.ByteReadChannel
import io.ktor.utils.io.jvm.javaio.toInputStream
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext
import java.nio.file.Files
import java.nio.file.Path

object PipePipeBackupUploadWriter {
fun writeWithLimit(channel: ByteReadChannel, target: Path, maxBytes: Long): Long {
suspend fun writeWithLimit(channel: ByteReadChannel, target: Path, maxBytes: Long): Long = withContext(Dispatchers.IO) {
var written = 0L
channel.toInputStream().use { input ->
Files.newOutputStream(target).use { output ->
Expand All @@ -20,6 +22,6 @@ object PipePipeBackupUploadWriter {
}
}
}
return written
written
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@ package dev.typetype.server.services

import io.ktor.utils.io.ByteReadChannel
import io.ktor.utils.io.jvm.javaio.toInputStream
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext
import java.nio.file.Files
import java.nio.file.Path

object YoutubeTakeoutUploadWriter {
fun writeWithLimit(channel: ByteReadChannel, target: Path, maxBytes: Long): Long {
suspend fun writeWithLimit(channel: ByteReadChannel, target: Path, maxBytes: Long): Long = withContext(Dispatchers.IO) {
var written = 0L
channel.toInputStream().use { input ->
Files.newOutputStream(target).use { output ->
Expand All @@ -20,6 +22,6 @@ object YoutubeTakeoutUploadWriter {
}
}
}
return written
written
}
}