Skip to content

Commit fb95a5d

Browse files
committed
feat: backup
1 parent 48ffed7 commit fb95a5d

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

src/main/kotlin/io/github/gnuf0rce/mirai/github/GitHubReleasePluginUpdater.kt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,8 @@ public object GitHubReleasePluginUpdater {
111111
?.let { File(it.path) }
112112
?: continue
113113
var needUpdate = false
114-
val download = PluginManager.pluginsFolder.resolve(plugin.description.id + ".download")
114+
val download = PluginManager.pluginsFolder.resolve("${plugin.description.id}.download")
115+
val backup = PluginManager.pluginsFolder.resolve("${source.name}.bak")
115116

116117
plugin.launch(CoroutineName("update from github")) {
117118
val latest = try {
@@ -173,10 +174,10 @@ public object GitHubReleasePluginUpdater {
173174
plugin.logger.warning("$id 升级失败")
174175
download.deleteOnExit()
175176
} else if (needUpdate) {
176-
plugin.logger.info("旧版插件 ${source.name} 将尝试添加退出时删除,请在下次启动时手动检查")
177+
plugin.logger.info("旧版插件 ${source.name} 将尝试添加退出时删除(备份),请在下次启动时手动检查")
177178
Runtime.getRuntime().addShutdownHook(Thread {
178179
classLoader.close()
179-
source.delete()
180+
source.renameTo(backup)
180181
})
181182
}
182183
}

0 commit comments

Comments
 (0)