mirror of
https://github.com/Suwayomi/Tachidesk.git
synced 2025-12-10 06:42:07 +01:00
bundle WebUI for stable builds
This commit is contained in:
2
.github/workflows/publish.yml
vendored
2
.github/workflows/publish.yml
vendored
@@ -65,7 +65,7 @@ jobs:
|
||||
with:
|
||||
build-root-directory: master
|
||||
wrapper-directory: master
|
||||
arguments: :webUI:copyBuild :server:shadowJar --stacktrace
|
||||
arguments: :server:downloadWebUI :server:shadowJar --stacktrace
|
||||
wrapper-cache-enabled: true
|
||||
dependencies-cache-enabled: true
|
||||
configuration-cache-enabled: true
|
||||
|
||||
2
.gitignore
vendored
2
.gitignore
vendored
@@ -6,7 +6,7 @@ gradle.properties
|
||||
# Ignore Gradle build output directory
|
||||
build
|
||||
|
||||
server/src/main/resources/webUI
|
||||
server/src/main/resources/WebUI.zip
|
||||
server/tmp/
|
||||
server/tachiserver-data/
|
||||
|
||||
|
||||
@@ -181,6 +181,12 @@ tasks {
|
||||
|
||||
named<Copy>("processResources") {
|
||||
duplicatesStrategy = DuplicatesStrategy.INCLUDE
|
||||
mustRunAfter("downloadWebUI")
|
||||
}
|
||||
|
||||
register<de.undercouch.gradle.tasks.download.Download>("downloadWebUI") {
|
||||
src("https://github.com/Suwayomi/Tachidesk-WebUI-preview/releases/download/$webUIRevisionTag/Tachidesk-WebUI-$webUIRevisionTag.zip")
|
||||
dest("src/main/resources/WebUI.zip")
|
||||
}
|
||||
|
||||
withType<LintTask> {
|
||||
|
||||
@@ -53,40 +53,56 @@ fun setupWebUI() {
|
||||
} else {
|
||||
File(applicationDirs.webUIRoot).deleteRecursively()
|
||||
|
||||
// download webUI zip
|
||||
val webUIZip = "Tachidesk-WebUI-${BuildConfig.WEBUI_TAG}.zip"
|
||||
val webUIZipPath = "$tmpDir/$webUIZip"
|
||||
val webUIZipURL = "${BuildConfig.WEBUI_REPO}/releases/download/${BuildConfig.WEBUI_TAG}/$webUIZip"
|
||||
val webUIZipFile = File(webUIZipPath)
|
||||
webUIZipFile.delete()
|
||||
|
||||
logger.info { "Downloading WebUI zip from the Internet..." }
|
||||
val data = ByteArray(1024)
|
||||
// try with resources first
|
||||
val resourceWebUI = try {
|
||||
BuildConfig::class.java.getResourceAsStream("/WebUI.zip")
|
||||
} catch (e: NullPointerException) { null }
|
||||
|
||||
webUIZipFile.outputStream().use { webUIZipFileOut ->
|
||||
BufferedInputStream(URL(webUIZipURL).openStream()).use { inp ->
|
||||
var totalCount = 0
|
||||
var tresh = 0
|
||||
while (true) {
|
||||
val count = inp.read(data, 0, 1024)
|
||||
totalCount += count
|
||||
if (totalCount > tresh + 10 * 1024) {
|
||||
tresh = totalCount
|
||||
print(" *")
|
||||
if (resourceWebUI == null) { // is not bundled
|
||||
// download webUI zip
|
||||
val webUIZipURL = "${BuildConfig.WEBUI_REPO}/releases/download/${BuildConfig.WEBUI_TAG}/$webUIZip"
|
||||
webUIZipFile.delete()
|
||||
|
||||
logger.info { "Downloading WebUI zip from the Internet..." }
|
||||
val data = ByteArray(1024)
|
||||
|
||||
webUIZipFile.outputStream().use { webUIZipFileOut ->
|
||||
BufferedInputStream(URL(webUIZipURL).openStream()).use { inp ->
|
||||
var totalCount = 0
|
||||
var tresh = 0
|
||||
while (true) {
|
||||
val count = inp.read(data, 0, 1024)
|
||||
totalCount += count
|
||||
if (totalCount > tresh + 10 * 1024) {
|
||||
tresh = totalCount
|
||||
print(" *")
|
||||
}
|
||||
if (count == -1)
|
||||
break
|
||||
webUIZipFileOut.write(data, 0, count)
|
||||
}
|
||||
if (count == -1)
|
||||
break
|
||||
webUIZipFileOut.write(data, 0, count)
|
||||
println()
|
||||
logger.info { "Downloading WebUI Done." }
|
||||
}
|
||||
}
|
||||
} else {
|
||||
logger.info { "Using the bundled WebUI zip..." }
|
||||
|
||||
resourceWebUI.use { input ->
|
||||
webUIZipFile.outputStream().use { output ->
|
||||
input.copyTo(output)
|
||||
}
|
||||
println()
|
||||
logger.info { "Downloading WebUI Done." }
|
||||
}
|
||||
}
|
||||
|
||||
// extract webUI zip
|
||||
logger.info { "Extracting downloaded WebUI zip..." }
|
||||
logger.info { "Extracting WebUI zip..." }
|
||||
File(applicationDirs.webUIRoot).mkdirs()
|
||||
ZipFile(webUIZipPath).extractAll(applicationDirs.webUIRoot)
|
||||
logger.info { "Extracting downloaded WebUI zip Done." }
|
||||
logger.info { "Extracting WebUI zip Done." }
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user