mirror of
https://github.com/gitbucket/gitbucket.git
synced 2025-11-12 16:35:52 +01:00
Add null check
This commit is contained in:
@@ -134,23 +134,25 @@ class InitializeListener extends ServletContextListener with SystemSettingsServi
|
|||||||
val cl = Thread.currentThread.getContextClassLoader
|
val cl = Thread.currentThread.getContextClassLoader
|
||||||
try {
|
try {
|
||||||
using(cl.getResourceAsStream("plugins/plugins.json")){ pluginsFile =>
|
using(cl.getResourceAsStream("plugins/plugins.json")){ pluginsFile =>
|
||||||
val pluginsJson = IOUtils.toString(pluginsFile, "UTF-8")
|
if(pluginsFile != null){
|
||||||
|
val pluginsJson = IOUtils.toString(pluginsFile, "UTF-8")
|
||||||
|
|
||||||
FileUtils.forceMkdir(PluginRepository.LocalRepositoryDir)
|
FileUtils.forceMkdir(PluginRepository.LocalRepositoryDir)
|
||||||
FileUtils.write(PluginRepository.LocalRepositoryIndexFile, pluginsJson, "UTF-8")
|
FileUtils.write(PluginRepository.LocalRepositoryIndexFile, pluginsJson, "UTF-8")
|
||||||
|
|
||||||
val plugins = PluginRepository.parsePluginJson(pluginsJson)
|
val plugins = PluginRepository.parsePluginJson(pluginsJson)
|
||||||
plugins.foreach { plugin =>
|
plugins.foreach { plugin =>
|
||||||
plugin.versions.sortBy { x => Semver.valueOf(x.version) }.reverse.zipWithIndex.foreach { case (version, i) =>
|
plugin.versions.sortBy { x => Semver.valueOf(x.version) }.reverse.zipWithIndex.foreach { case (version, i) =>
|
||||||
val file = new File(PluginRepository.LocalRepositoryDir, version.file)
|
val file = new File(PluginRepository.LocalRepositoryDir, version.file)
|
||||||
if(!file.exists) {
|
if(!file.exists) {
|
||||||
logger.info(s"Copy ${plugin} to ${file.getAbsolutePath}")
|
logger.info(s"Copy ${plugin} to ${file.getAbsolutePath}")
|
||||||
FileUtils.forceMkdirParent(file)
|
FileUtils.forceMkdirParent(file)
|
||||||
using(cl.getResourceAsStream("plugins/" + version.file), new FileOutputStream(file)){ case (in, out) => IOUtils.copy(in, out) }
|
using(cl.getResourceAsStream("plugins/" + version.file), new FileOutputStream(file)){ case (in, out) => IOUtils.copy(in, out) }
|
||||||
|
|
||||||
if(plugin.default && i == 0){
|
if(plugin.default && i == 0){
|
||||||
logger.info(s"Enable ${file.getName} in default")
|
logger.info(s"Enable ${file.getName} in default")
|
||||||
FileUtils.copyFile(file, new File(PluginHome, version.file))
|
FileUtils.copyFile(file, new File(PluginHome, version.file))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user