Skip to content

Commit

Permalink
feat: backup
Browse files Browse the repository at this point in the history
  • Loading branch information
cssxsh committed Jul 20, 2023
1 parent 48ffed7 commit fb95a5d
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,8 @@ public object GitHubReleasePluginUpdater {
?.let { File(it.path) }
?: continue
var needUpdate = false
val download = PluginManager.pluginsFolder.resolve(plugin.description.id + ".download")
val download = PluginManager.pluginsFolder.resolve("${plugin.description.id}.download")
val backup = PluginManager.pluginsFolder.resolve("${source.name}.bak")

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

0 comments on commit fb95a5d

Please sign in to comment.