/ Halo / 18浏览

[Halo] 开发主题压缩后上传主题报错Failed to unzip theme

大致报错信息(日志输出):

2024-09-07 12:49:04 2024-09-07T12:49:04.354+08:00 ERROR 7 --- [undedElastic-32] r.h.app.core.extension.theme.ThemeUtils  : Failed to unzip theme
2024-09-07 12:49:04 
2024-09-07 12:49:04 java.lang.IllegalArgumentException: malformed input off : 45, length : 1
2024-09-07 12:49:04     at java.base/java.lang.String.throwMalformed(Unknown Source) ~[na:na]
2024-09-07 12:49:04     at java.base/java.lang.String.decodeUTF8_UTF16(Unknown Source) ~[na:na]
2024-09-07 12:49:04     at java.base/java.lang.String.newStringUTF8NoRepl(Unknown Source) ~[na:na]
2024-09-07 12:49:04     at java.base/java.lang.Access.newStringUTF8NoRepl(Unknown Source) ~[na:na]
2024-09-07 12:49:04     at java.base/java.util.zip.ZipCoder$UTF8ZipCoder.toString(Unknown Source) ~[na:na]
2024-09-07 12:49:04     at java.base/java.util.zip.ZipCoder.toString(Unknown Source) ~[na:na]
2024-09-07 12:49:04     at java.base/java.util.zip.ZipInputStream.readLOC(Unknown Source) ~[na:na]
2024-09-07 12:49:04     at java.base/java.util.zip.ZipInputStream.getNextEntry(Unknown Source) ~[na:na]
2024-09-07 12:49:04     at run.halo.app.infra.utils.FileUtils.unzip(FileUtils.java:100) ~[classes/:na]
2024-09-07 12:49:04     at run.halo.app.infra.utils.FileUtils.lambda$unzip$0(FileUtils.java:57) ~[classes/:na]
2024-09-07 12:49:04     at reactor.core.publisher.MonoUsingWhen.deriveMonoFromResource(MonoUsingWhen.java:114) ~[reactor-core-3.6.9.jar:3.6.9]
2024-09-07 12:49:04     at reactor.core.publisher.MonoUsingWhen.access$000(MonoUsingWhen.java:46) ~[reactor-core-3.6.9.jar:3.6.9]
2024-09-07 12:49:04     at reactor.core.publisher.MonoUsingWhen$ResourceSubscriber.onNext(MonoUsingWhen.java:181) ~[reactor-core-3.6.9.jar:3.6.9]
2024-09-07 12:49:04     at reactor.core.publisher.MonoCreate$DefaultMonoSink.success(MonoCreate.java:176) ~[reactor-core-3.6.9.jar:3.6.9]
2024-09-07 12:49:04     at run.halo.app.infra.utils.DataBufferUtils.lambda$toInputStream$1(DataBufferUtils.java:37) ~[classes/:na]
2024-09-07 12:49:04     at reactor.core.publisher.MonoCreate.subscribe(MonoCreate.java:61) ~[reactor-core-3.6.9.jar:3.6.9]
2024-09-07 12:49:04     at reactor.core.publisher.Mono.subscribe(Mono.java:4576) ~[reactor-core-3.6.9.jar:3.6.9]
2024-09-07 12:49:04     at reactor.core.publisher.MonoUsingWhen.subscribe(MonoUsingWhen.java:97) ~[reactor-core-3.6.9.jar:3.6.9]
2024-09-07 12:49:04     at reactor.core.publisher.Mono.subscribe(Mono.java:4576) ~[reactor-core-3.6.9.jar:3.6.9]
2024-09-07 12:49:04     at reactor.core.publisher.MonoIgnoreThen$ThenIgnoreMain.subscribeNext(MonoIgnoreThen.java:265) ~[reactor-core-3.6.9.jar:3.6.9]
2024-09-07 12:49:04     at reactor.core.publisher.MonoIgnoreThen.subscribe(MonoIgnoreThen.java:51) ~[reactor-core-3.6.9.jar:3.6.9]
2024-09-07 12:49:04     at reactor.core.publisher.Mono.subscribe(Mono.java:4576) ~[reactor-core-3.6.9.jar:3.6.9]
2024-09-07 12:49:04     at reactor.core.publisher.MonoSubscribeOn$SubscribeOnSubscriber.run(MonoSubscribeOn.java:126) ~[reactor-core-3.6.9.jar:3.6.9]
2024-09-07 12:49:04     at reactor.core.scheduler.WorkerTask.call(WorkerTask.java:84) ~[reactor-core-3.6.9.jar:3.6.9]
2024-09-07 12:49:04     at reactor.core.scheduler.WorkerTask.call(WorkerTask.java:37) ~[reactor-core-3.6.9.jar:3.6.9]
2024-09-07 12:49:04     at java.base/java.util.concurrent.FutureTask.run(Unknown Source) ~[na:na]
2024-09-07 12:49:04     at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(Unknown Source) ~[na:na]
2024-09-07 12:49:04     at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) ~[na:na]
2024-09-07 12:49:04     at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) ~[na:na]
2024-09-07 12:49:04     at java.base/java.lang.Thread.run(Unknown Source) ~[na:na]
2024-09-07 12:49:04 Caused by: java.nio.charset.MalformedInputException: Input length = 1
2024-09-07 12:49:04     ... 30 common frames omitted
2024-09-07 12:49:04

后台上传时报错404

发生了什么?

使用docker在本地部署主题,使用Visual Studio Code开发,开发后压缩了这几个文件。上传的时候报错400,具体日志在上边,已经确认了yaml整理后没有问题,明显是压缩的问题?


解决方案:

安装bandzip压缩文件:

https://www.bandisoft.com/bandizip/

设置中勾选:在 Zip 文件中使用 Unicode 文件名(UTF-8)

重新打包上传。

其他解决方案:

在压缩完没有解决后查看文件格式是否正确?

theme.yaml
settings.yaml

yaml在线格式化:https://www.bejson.com/validators/yaml_editor/