Skip to content

Commit 315aa60

Browse files
Him188inshinno
authored andcommitted
Add createAutoCloseable back, close mamoe#1856 (caused by mamoe#1742 (PR mamoe#1774))
1 parent 09ce395 commit 315aa60

File tree

3 files changed

+24
-2
lines changed

3 files changed

+24
-2
lines changed

mirai-core-api/compatibility-validation/android/api/android.api

+2
Original file line numberDiff line numberDiff line change
@@ -5881,6 +5881,7 @@ public abstract interface class net/mamoe/mirai/utils/ExternalResource : java/io
58815881
public static fun create (Ljava/io/RandomAccessFile;Ljava/lang/String;Z)Lnet/mamoe/mirai/utils/ExternalResource;
58825882
public static fun create ([B)Lnet/mamoe/mirai/utils/ExternalResource;
58835883
public static fun create ([BLjava/lang/String;)Lnet/mamoe/mirai/utils/ExternalResource;
5884+
public static synthetic fun createAutoCloseable (Lnet/mamoe/mirai/utils/ExternalResource;)Lnet/mamoe/mirai/utils/ExternalResource;
58845885
public abstract fun getClosed ()Lkotlinx/coroutines/Deferred;
58855886
public abstract fun getFormatName ()Ljava/lang/String;
58865887
public abstract fun getMd5 ()[B
@@ -5945,6 +5946,7 @@ public final class net/mamoe/mirai/utils/ExternalResource$Companion {
59455946
public static synthetic fun create$default (Lnet/mamoe/mirai/utils/ExternalResource$Companion;Ljava/io/InputStream;Ljava/lang/String;ILjava/lang/Object;)Lnet/mamoe/mirai/utils/ExternalResource;
59465947
public static synthetic fun create$default (Lnet/mamoe/mirai/utils/ExternalResource$Companion;Ljava/io/RandomAccessFile;Ljava/lang/String;ZILjava/lang/Object;)Lnet/mamoe/mirai/utils/ExternalResource;
59475948
public static synthetic fun create$default (Lnet/mamoe/mirai/utils/ExternalResource$Companion;[BLjava/lang/String;ILjava/lang/Object;)Lnet/mamoe/mirai/utils/ExternalResource;
5949+
public final synthetic fun createAutoCloseable (Lnet/mamoe/mirai/utils/ExternalResource;)Lnet/mamoe/mirai/utils/ExternalResource;
59485950
public final fun sendAsFile (Lnet/mamoe/mirai/utils/ExternalResource;Lnet/mamoe/mirai/contact/FileSupported;Ljava/lang/String;)Lnet/mamoe/mirai/message/MessageReceipt;
59495951
public final fun sendAsFile (Lnet/mamoe/mirai/utils/ExternalResource;Lnet/mamoe/mirai/contact/FileSupported;Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
59505952
public final fun sendAsFile (Lnet/mamoe/mirai/utils/ExternalResource;Lnet/mamoe/mirai/contact/FileSupported;Ljava/lang/String;Lnet/mamoe/mirai/utils/RemoteFile$ProgressionCallback;)Lnet/mamoe/mirai/message/MessageReceipt;

mirai-core-api/compatibility-validation/jvm/api/jvm.api

+2
Original file line numberDiff line numberDiff line change
@@ -5881,6 +5881,7 @@ public abstract interface class net/mamoe/mirai/utils/ExternalResource : java/io
58815881
public static fun create (Ljava/io/RandomAccessFile;Ljava/lang/String;Z)Lnet/mamoe/mirai/utils/ExternalResource;
58825882
public static fun create ([B)Lnet/mamoe/mirai/utils/ExternalResource;
58835883
public static fun create ([BLjava/lang/String;)Lnet/mamoe/mirai/utils/ExternalResource;
5884+
public static synthetic fun createAutoCloseable (Lnet/mamoe/mirai/utils/ExternalResource;)Lnet/mamoe/mirai/utils/ExternalResource;
58845885
public abstract fun getClosed ()Lkotlinx/coroutines/Deferred;
58855886
public abstract fun getFormatName ()Ljava/lang/String;
58865887
public abstract fun getMd5 ()[B
@@ -5945,6 +5946,7 @@ public final class net/mamoe/mirai/utils/ExternalResource$Companion {
59455946
public static synthetic fun create$default (Lnet/mamoe/mirai/utils/ExternalResource$Companion;Ljava/io/InputStream;Ljava/lang/String;ILjava/lang/Object;)Lnet/mamoe/mirai/utils/ExternalResource;
59465947
public static synthetic fun create$default (Lnet/mamoe/mirai/utils/ExternalResource$Companion;Ljava/io/RandomAccessFile;Ljava/lang/String;ZILjava/lang/Object;)Lnet/mamoe/mirai/utils/ExternalResource;
59475948
public static synthetic fun create$default (Lnet/mamoe/mirai/utils/ExternalResource$Companion;[BLjava/lang/String;ILjava/lang/Object;)Lnet/mamoe/mirai/utils/ExternalResource;
5949+
public final synthetic fun createAutoCloseable (Lnet/mamoe/mirai/utils/ExternalResource;)Lnet/mamoe/mirai/utils/ExternalResource;
59485950
public final fun sendAsFile (Lnet/mamoe/mirai/utils/ExternalResource;Lnet/mamoe/mirai/contact/FileSupported;Ljava/lang/String;)Lnet/mamoe/mirai/message/MessageReceipt;
59495951
public final fun sendAsFile (Lnet/mamoe/mirai/utils/ExternalResource;Lnet/mamoe/mirai/contact/FileSupported;Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
59505952
public final fun sendAsFile (Lnet/mamoe/mirai/utils/ExternalResource;Lnet/mamoe/mirai/contact/FileSupported;Ljava/lang/String;Lnet/mamoe/mirai/utils/RemoteFile$ProgressionCallback;)Lnet/mamoe/mirai/message/MessageReceipt;

mirai-core-api/src/commonMain/kotlin/utils/ExternalResource.kt

+20-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2019-2021 Mamoe Technologies and contributors.
2+
* Copyright 2019-2022 Mamoe Technologies and contributors.
33
*
44
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
55
* Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
@@ -227,6 +227,24 @@ public interface ExternalResource : Closeable {
227227

228228
// endregion
229229

230+
231+
/* note:
232+
于 2.8.0-M1 添加 (#1392)
233+
234+
于 2.8.0-RC 移动至 `toExternalResource`(#1588)
235+
*/
236+
@JvmName("createAutoCloseable")
237+
@JvmStatic
238+
@Deprecated(
239+
level = DeprecationLevel.HIDDEN,
240+
message = "Moved to `toExternalResource()`",
241+
replaceWith = ReplaceWith("resource.toAutoCloseable()"),
242+
)
243+
@DeprecatedSinceMirai(errorSince = "2.8", hiddenSince = "2.10")
244+
public fun createAutoCloseable(resource: ExternalResource): ExternalResource {
245+
return resource.toAutoCloseable()
246+
}
247+
230248
///////////////////////////////////////////////////////////////////////////
231249
// region sendAsImageTo
232250
///////////////////////////////////////////////////////////////////////////
@@ -349,7 +367,7 @@ public interface ExternalResource : Closeable {
349367
* @see RemoteFile.path
350368
* @see RemoteFile.upload
351369
*/
352-
@Suppress("DEPRECATION","DEPRECATION_ERROR")
370+
@Suppress("DEPRECATION", "DEPRECATION_ERROR")
353371
@JvmStatic
354372
@JvmBlockingBridge
355373
@JvmOverloads

0 commit comments

Comments
 (0)