Commit 5cd027df authored by Him188's avatar Him188

Remove param `format` from `FileCacheStrategy.newImageCache`

parent d80ab160
......@@ -67,7 +67,7 @@ actual interface FileCacheStrategy {
*/
@MiraiExperimentalAPI
@Throws(IOException::class)
fun newImageCache(input: URL, format: String = "png"): ExternalImage
fun newImageCache(input: URL): ExternalImage
/**
* 默认的缓存方案, 使用系统临时文件夹存储.
......@@ -105,7 +105,7 @@ actual interface FileCacheStrategy {
}
@MiraiExperimentalAPI
override fun newImageCache(input: URL, format: String): ExternalImage {
override fun newImageCache(input: URL): ExternalImage {
val out = ByteArrayOutputStream()
input.openConnection().getInputStream().use { it.copyTo(out) }
return newImageCache(out.toByteArray())
......@@ -118,7 +118,7 @@ actual interface FileCacheStrategy {
@MiraiExperimentalAPI
class TempCache @JvmOverloads constructor(
/**
* 缓存图片存放位置
* 缓存图片存放位置. 为 `null` 时使用主机系统的临时文件夹
*/
val directory: File? = null
) : FileCacheStrategy {
......@@ -177,7 +177,7 @@ actual interface FileCacheStrategy {
}
@MiraiExperimentalAPI
override fun newImageCache(input: URL, format: String): ExternalImage {
override fun newImageCache(input: URL): ExternalImage {
return ExternalImage(createTempFile(directory = directory).apply {
deleteOnExit()
input.openConnection().getInputStream().withOut(this.outputStream()) { copyTo(it) }
......@@ -194,11 +194,6 @@ internal inline fun <I : Closeable, O : Closeable, R> I.withOut(output: O, block
return use { output.use { block(this, output) } }
}
/**
* Copies this stream to the given output stream, returning the number of bytes copied
*
* **Note** It is the caller's responsibility to close both of these resources.
*/
@Throws(IOException::class)
internal fun Input.copyTo(out: OutputStream, bufferSize: Int = DEFAULT_BUFFER_SIZE): Long {
var bytesCopied: Long = 0
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment