[core] Raise deprecation level for RemoteFile to ERROR (for v2.14)

This commit is contained in:
Him188 2022-12-27 14:32:36 +00:00
parent c2611dda94
commit 76a70f596f
No known key found for this signature in database
GPG Key ID: BA439CDDCF652375
9 changed files with 46 additions and 23 deletions

View File

@ -28,11 +28,17 @@ public actual interface FileSupported : Contact {
/** /**
* 文件根目录. 可通过 [net.mamoe.mirai.utils.RemoteFile.listFiles] 获取目录下文件列表. * 文件根目录. 可通过 [net.mamoe.mirai.utils.RemoteFile.listFiles] 获取目录下文件列表.
* *
* **注意:** 已弃用, 请使用 [files].
*
* @since 2.5 * @since 2.5
*/ */
@Suppress("DEPRECATION") @Suppress("DEPRECATION", "DEPRECATION_ERROR")
@Deprecated("Please use files instead.", replaceWith = ReplaceWith("files.root")) // deprecated since 2.8.0-RC @Deprecated(
@DeprecatedSinceMirai(warningSince = "2.8") "Please use files instead.",
replaceWith = ReplaceWith("files.root"),
level = DeprecationLevel.ERROR
) // deprecated since 2.8.0-RC
@DeprecatedSinceMirai(warningSince = "2.8", errorSince = "2.14")
public val filesRoot: net.mamoe.mirai.utils.RemoteFile public val filesRoot: net.mamoe.mirai.utils.RemoteFile
/** /**

View File

@ -75,9 +75,13 @@ public actual interface FileMessage : MessageContent, ConstrainSingle, CodableMe
/** /**
* 获取一个对应的 [RemoteFile]. 当目标群或好友不存在这个文件时返回 `null`. * 获取一个对应的 [RemoteFile]. 当目标群或好友不存在这个文件时返回 `null`.
*/ */
@Suppress("DEPRECATION") @Suppress("DEPRECATION", "DEPRECATION_ERROR")
@Deprecated("Please use toAbsoluteFile", ReplaceWith("this.toAbsoluteFile(contact)")) // deprecated since 2.8.0-RC @Deprecated(
@DeprecatedSinceMirai(warningSince = "2.8") "Please use toAbsoluteFile",
ReplaceWith("this.toAbsoluteFile(contact)"),
level = DeprecationLevel.ERROR
) // deprecated since 2.8.0-RC
@DeprecatedSinceMirai(warningSince = "2.8", errorSince = "2.14")
public suspend fun toRemoteFile(contact: FileSupported): RemoteFile? { public suspend fun toRemoteFile(contact: FileSupported): RemoteFile? {
@Suppress("DEPRECATION") @Suppress("DEPRECATION")
return contact.filesRoot.resolveById(id) return contact.filesRoot.resolveById(id)

View File

@ -558,12 +558,13 @@ public actual interface ExternalResource : Closeable {
@Suppress("DEPRECATION_ERROR", "DEPRECATION") @Suppress("DEPRECATION_ERROR", "DEPRECATION")
@Deprecated( @Deprecated(
"Deprecated. Please use AbsoluteFolder.uploadNewFile", "Deprecated. Please use AbsoluteFolder.uploadNewFile",
ReplaceWith("contact.files.uploadNewFile(path, this, callback)") ReplaceWith("contact.files.uploadNewFile(path, this, callback)"),
level = DeprecationLevel.ERROR,
) // deprecated since 2.8.0-RC ) // deprecated since 2.8.0-RC
@JvmStatic @JvmStatic
@JvmBlockingBridge @JvmBlockingBridge
@JvmOverloads @JvmOverloads
@DeprecatedSinceMirai(warningSince = "2.8") @DeprecatedSinceMirai(warningSince = "2.8", errorSince = "2.14")
public suspend fun <C : FileSupported> File.sendTo( public suspend fun <C : FileSupported> File.sendTo(
contact: C, contact: C,
path: String, path: String,
@ -585,13 +586,14 @@ public actual interface ExternalResource : Closeable {
@Suppress("DEPRECATION", "DEPRECATION_ERROR") @Suppress("DEPRECATION", "DEPRECATION_ERROR")
@Deprecated( @Deprecated(
"Deprecated. Please use AbsoluteFolder.uploadNewFile", "Deprecated. Please use AbsoluteFolder.uploadNewFile",
ReplaceWith("contact.files.uploadNewFile(path, this, callback)") ReplaceWith("contact.files.uploadNewFile(path, this, callback)"),
level = DeprecationLevel.ERROR
) // deprecated since 2.8.0-RC ) // deprecated since 2.8.0-RC
@JvmStatic @JvmStatic
@JvmBlockingBridge @JvmBlockingBridge
@JvmName("sendAsFile") @JvmName("sendAsFile")
@JvmOverloads @JvmOverloads
@DeprecatedSinceMirai(warningSince = "2.8") @DeprecatedSinceMirai(warningSince = "2.8", errorSince = "2.14")
public suspend fun <C : FileSupported> ExternalResource.sendAsFileTo( public suspend fun <C : FileSupported> ExternalResource.sendAsFileTo(
contact: C, contact: C,
path: String, path: String,

View File

@ -7,7 +7,7 @@
* https://github.com/mamoe/mirai/blob/dev/LICENSE * https://github.com/mamoe/mirai/blob/dev/LICENSE
*/ */
@file:Suppress("unused", "DEPRECATION") @file:Suppress("unused", "DEPRECATION", "DEPRECATION_ERROR")
@file:JvmBlockingBridge @file:JvmBlockingBridge
package net.mamoe.mirai.utils package net.mamoe.mirai.utils
@ -20,6 +20,7 @@ import me.him188.kotlin.jvm.blocking.bridge.JvmBlockingBridge
import net.mamoe.mirai.contact.Contact import net.mamoe.mirai.contact.Contact
import net.mamoe.mirai.contact.FileSupported import net.mamoe.mirai.contact.FileSupported
import net.mamoe.mirai.contact.Group import net.mamoe.mirai.contact.Group
import net.mamoe.mirai.contact.file.AbsoluteFile
import net.mamoe.mirai.message.MessageReceipt import net.mamoe.mirai.message.MessageReceipt
import net.mamoe.mirai.message.data.FileMessage import net.mamoe.mirai.message.data.FileMessage
import net.mamoe.mirai.message.data.sendTo import net.mamoe.mirai.message.data.sendTo
@ -31,6 +32,8 @@ import java.io.File
/** /**
* 表示一个远程文件或目录. * 表示一个远程文件或目录.
* *
* # 注意: API 已弃用, 请使用 [AbsoluteFile] 代替.
*
* [RemoteFile] 仅保存 [id], [name], [path], [parent], [contact] 这五个属性, 除获取这些属性外的所有的操作都是在*远程*完成的. * [RemoteFile] 仅保存 [id], [name], [path], [parent], [contact] 这五个属性, 除获取这些属性外的所有的操作都是在*远程*完成的.
* 意味着操作的结果会因文件或目录在服务器中的状态变化而变化. * 意味着操作的结果会因文件或目录在服务器中的状态变化而变化.
* *
@ -99,9 +102,9 @@ import java.io.File
*/ */
@Deprecated( @Deprecated(
"Please use RemoteFiles and AbsoluteFileFolder form fileSupported.files", "Please use RemoteFiles and AbsoluteFileFolder form fileSupported.files",
level = DeprecationLevel.WARNING level = DeprecationLevel.ERROR
) // deprecated since 2.8.0-RC ) // deprecated since 2.8.0-RC
@DeprecatedSinceMirai(warningSince = "2.8") @DeprecatedSinceMirai(warningSince = "2.8", errorSince = "2.14")
@NotStableForInheritance @NotStableForInheritance
public interface RemoteFile { public interface RemoteFile {
/** /**
@ -146,6 +149,8 @@ public interface RemoteFile {
*/ */
public suspend fun length(): Long public suspend fun length(): Long
@Deprecated("RemoteFile is deprecated. Use RemoteFiles instead.", level = DeprecationLevel.ERROR)
@DeprecatedSinceMirai(errorSince = "2.14") // 在弃用 RemoteFile 的时候忘了弃用这个类, 所以它没有 warningSince
public class FileInfo @MiraiInternalApi constructor( public class FileInfo @MiraiInternalApi constructor(
/** /**
* 文件或目录名. * 文件或目录名.
@ -358,9 +363,9 @@ public interface RemoteFile {
@Deprecated( @Deprecated(
"Deprecated without replacement. Please use AbsoluteFolder.uploadNewFile", "Deprecated without replacement. Please use AbsoluteFolder.uploadNewFile",
ReplaceWith("contact.files.uploadNewFile(path, this, callback)"), ReplaceWith("contact.files.uploadNewFile(path, this, callback)"),
level = DeprecationLevel.WARNING level = DeprecationLevel.ERROR
) // deprecated since 2.8.0-RC ) // deprecated since 2.8.0-RC
@DeprecatedSinceMirai(warningSince = "2.8") @DeprecatedSinceMirai(warningSince = "2.8", errorSince = "2.14")
public interface ProgressionCallback { public interface ProgressionCallback {
/** /**
* 当上传开始时调用 * 当上传开始时调用
@ -384,6 +389,8 @@ public interface RemoteFile {
*/ */
public fun onFailure(file: RemoteFile, resource: ExternalResource, exception: Throwable) {} public fun onFailure(file: RemoteFile, resource: ExternalResource, exception: Throwable) {}
@Deprecated("RemoteFile is deprecated. Use RemoteFiles instead.", level = DeprecationLevel.ERROR)
@DeprecatedSinceMirai(errorSince = "2.14") // 在弃用 RemoteFile 的时候忘了弃用这个类, 所以它没有 warningSince
public companion object { public companion object {
/** /**
* 将一个 [SendChannel] 作为 [ProgressionCallback] 使用. * 将一个 [SendChannel] 作为 [ProgressionCallback] 使用.
@ -537,6 +544,8 @@ public interface RemoteFile {
*/ */
public suspend fun getDownloadInfo(): DownloadInfo? public suspend fun getDownloadInfo(): DownloadInfo?
@Deprecated("RemoteFile is deprecated. Use RemoteFiles instead.", level = DeprecationLevel.ERROR)
@DeprecatedSinceMirai(errorSince = "2.14") // 在弃用 RemoteFile 的时候忘了弃用这个类, 所以它没有 warningSince
public class DownloadInfo @MiraiInternalApi constructor( public class DownloadInfo @MiraiInternalApi constructor(
/** /**
* @see RemoteFile.name * @see RemoteFile.name
@ -564,6 +573,8 @@ public interface RemoteFile {
} }
} }
@Deprecated("RemoteFile is deprecated. Use RemoteFiles instead.", level = DeprecationLevel.ERROR)
@DeprecatedSinceMirai(errorSince = "2.14") // 在弃用 RemoteFile 的时候忘了弃用这个类, 所以它没有 warningSince
public companion object { public companion object {
/** /**
* 根目录路径 * 根目录路径
@ -591,7 +602,7 @@ public interface RemoteFile {
), ),
level = DeprecationLevel.ERROR level = DeprecationLevel.ERROR
) // deprecated since 2.7-M1 ) // deprecated since 2.7-M1
@DeprecatedSinceMirai(warningSince = "2.7", errorSince = "2.10") // left ERROR intentionally @DeprecatedSinceMirai(warningSince = "2.7", errorSince = "2.10")
@Suppress("_FUNCTION_WITH_DEFAULT_ARGUMENTS") @Suppress("_FUNCTION_WITH_DEFAULT_ARGUMENTS")
public suspend fun FileSupported.uploadFile( public suspend fun FileSupported.uploadFile(
path: String, path: String,

View File

@ -338,7 +338,7 @@ internal class MockGroupImpl(
} }
@Deprecated("Please use files instead.", replaceWith = ReplaceWith("files.root")) @Deprecated("Please use files instead.", replaceWith = ReplaceWith("files.root"))
@Suppress("OverridingDeprecatedMember", "DEPRECATION") @Suppress("OverridingDeprecatedMember", "DEPRECATION", "DEPRECATION_ERROR")
override val filesRoot: RemoteFile by lazy { override val filesRoot: RemoteFile by lazy {
net.mamoe.mirai.mock.internal.remotefile.remotefile.RootRemoteFile(txFileSystem, this) net.mamoe.mirai.mock.internal.remotefile.remotefile.RootRemoteFile(txFileSystem, this)
} }

View File

@ -7,7 +7,7 @@
* https://github.com/mamoe/mirai/blob/dev/LICENSE * https://github.com/mamoe/mirai/blob/dev/LICENSE
*/ */
@file:Suppress("DEPRECATION", "INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") @file:Suppress("DEPRECATION", "DEPRECATION_ERROR", "INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
package net.mamoe.mirai.mock.internal.remotefile.remotefile package net.mamoe.mirai.mock.internal.remotefile.remotefile

View File

@ -145,7 +145,7 @@ internal class MockGroupTest : MockBotTestBase() {
} }
} }
@Suppress("DEPRECATION") @Suppress("DEPRECATION", "DEPRECATION_ERROR")
@Test @Test
internal fun testGroupFileV1() = runTest { internal fun testGroupFileV1() = runTest {
val fsroot = bot.addGroup(5417, "58aw").filesRoot val fsroot = bot.addGroup(5417, "58aw").filesRoot

View File

@ -26,8 +26,8 @@ internal actual class GroupImpl actual constructor(
) : Group, CommonGroupImpl(bot, parentCoroutineContext, id, groupInfo, members) { ) : Group, CommonGroupImpl(bot, parentCoroutineContext, id, groupInfo, members) {
actual companion object; actual companion object;
@Suppress("DEPRECATION") @Suppress("DEPRECATION_ERROR")
@Deprecated("Please use files instead.", replaceWith = ReplaceWith("files.root"), level = DeprecationLevel.WARNING) @Deprecated("Please use files instead.", replaceWith = ReplaceWith("files.root"), level = DeprecationLevel.ERROR)
@DeprecatedSinceMirai(warningSince = "2.8") @DeprecatedSinceMirai(warningSince = "2.8", errorSince = "2.14")
override val filesRoot: net.mamoe.mirai.utils.RemoteFile by lazy { RemoteFileImpl(this, "/") } override val filesRoot: net.mamoe.mirai.utils.RemoteFile by lazy { RemoteFileImpl(this, "/") }
} }

View File

@ -7,7 +7,7 @@
* https://github.com/mamoe/mirai/blob/dev/LICENSE * https://github.com/mamoe/mirai/blob/dev/LICENSE
*/ */
@file:Suppress("DEPRECATION") @file:Suppress("DEPRECATION", "DEPRECATION_ERROR")
package net.mamoe.mirai.internal.utils package net.mamoe.mirai.internal.utils