Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] 无法查看未经过GZIP压缩的.dat(nbt文件) #2687

Closed
wifi-left opened this issue Jan 26, 2024 · 12 comments
Closed

[Bug] 无法查看未经过GZIP压缩的.dat(nbt文件) #2687

wifi-left opened this issue Jan 26, 2024 · 12 comments
Assignees
Labels

Comments

@wifi-left
Copy link
Contributor

平台 | Platform

Windows 11

问题描述 | Problem Description

#2402 的一个小问题:
FS8R0QELM$E$M5Y42(B}QJ1

启动器崩溃报告 / 启动器日志文件 | Launcher Crash Report / Launcher Log File

暂无(Q群里的)

@wifi-left wifi-left added the bug label Jan 26, 2024
@zkitefly
Copy link
Member

servers.dat

不知道支不支持 servers.dat 的读取,我拖进去的是 servers.dat 而不是 level.dat

hmcl-exported-logs-2024-01-26T20-54-35.log

@burningtnt
Copy link
Member

burningtnt commented Jan 26, 2024

DAT 文件必须被 GZIP 压缩,你确定你手上的文件是一个标准的 NBT 文件
image

@wifi-left
Copy link
Contributor Author

wifi-left commented Jan 26, 2024

servers.dat 确实没有经过 gzip压缩
补一份日志:

[20:55:52] [org.jackhuang.hmcl.ui.nbt.NBTEditorPage.lambda$new$4/WARNING] Fail to open nbt file
java.util.concurrent.CompletionException: java.util.zip.ZipException: Not in GZIP format
        at org.jackhuang.hmcl.util.Lang.rethrow(Lang.java:284)
        at org.jackhuang.hmcl.util.Lang.lambda$wrap$3(Lang.java:303)
        at java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1604)
        at java.util.concurrent.CompletableFuture$AsyncSupply.exec(CompletableFuture.java:1596)
        at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289)
        at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1056)
        at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1692)
        at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:175)
Caused by: java.util.zip.ZipException: Not in GZIP format
        at java.util.zip.GZIPInputStream.readHeader(GZIPInputStream.java:165)
        at java.util.zip.GZIPInputStream.<init>(GZIPInputStream.java:79)
        at java.util.zip.GZIPInputStream.<init>(GZIPInputStream.java:91)
        at org.jackhuang.hmcl.ui.nbt.NBTFileType$1.read(NBTFileType.java:20)
        at org.jackhuang.hmcl.ui.nbt.NBTFileType.readAsTree(NBTFileType.java:144)
        at org.jackhuang.hmcl.ui.nbt.NBTEditorPage.lambda$new$2(NBTEditorPage.java:69)
        at org.jackhuang.hmcl.util.Lang.lambda$wrap$3(Lang.java:301)
        ... 6 more
[Fatal Error] :21:3: 元素类型 "init" 必须由匹配的结束标记 "</init>" 终止。
[20:55:52] [org.jackhuang.hmcl.ui.FXUtils.parseSegment/WARNING] Failed to parse xml
org.xml.sax.SAXParseException; lineNumber: 21; columnNumber: 3; 元素类型 "init" 必须由匹配的结束标记 "</init>" 终止。
        at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(DOMParser.java:257)
        at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:339)
        at org.jackhuang.hmcl.ui.FXUtils.parseSegment(FXUtils.java:920)
        at org.jackhuang.hmcl.ui.construct.MessageDialogPane$EnhancedTextFlow.<init>(MessageDialogPane.java:147)
        at org.jackhuang.hmcl.ui.construct.MessageDialogPane.<init>(MessageDialogPane.java:105)
        at org.jackhuang.hmcl.ui.construct.MessageDialogPane$Builder.<init>(MessageDialogPane.java:160)
        at org.jackhuang.hmcl.ui.Controllers.dialog(Controllers.java:325)
        at org.jackhuang.hmcl.ui.nbt.NBTEditorPage.lambda$new$4(NBTEditorPage.java:77)
        at java.util.concurrent.CompletableFuture.uniHandle(CompletableFuture.java:836)
        at java.util.concurrent.CompletableFuture$UniHandle.tryFire(CompletableFuture.java:811)
        at java.util.concurrent.CompletableFuture$Completion.run(CompletableFuture.java:456)
        at com.sun.javafx.application.PlatformImpl.lambda$null$5(PlatformImpl.java:295)
        at java.security.AccessController.doPrivileged(Native Method)
        at com.sun.javafx.application.PlatformImpl.lambda$runLater$6(PlatformImpl.java:294)
        at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
        at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
        at com.sun.glass.ui.win.WinApplication.lambda$null$3(WinApplication.java:177)
        at java.lang.Thread.run(Thread.java:748)
[20:55:52] [org.jackhuang.hmcl.ui.construct.StackContainerPane.push/INFO] StackContainerPane@4637a3a8 [MessageDialogPane@281bda8a[styleClass=jfx-dialog-layout]]
[20:55:55] [org.jackhuang.hmcl.ui.construct.StackContainerPane.pop/INFO] StackContainerPane@4637a3a8 [], removed: true, object: MessageDialogPane@281bda8a[styleClass=jfx-dialog-layout]
[20:55:55] [org.jackhuang.hmcl.ui.construct.Navigator.close/INFO] Closed page NBTEditorPage@12adda5d[styleClass=gray-background]

@wifi-left
Copy link
Contributor Author

wifi-left commented Jan 26, 2024

servers.dat 是正常的NBT文件
image
但其未经过GZIP压缩:
image

@wifi-left
Copy link
Contributor Author

wifi-left commented Jan 26, 2024

DAT 文件必须被 GZIP 压缩,你确定你手上的文件是一个标准的 NBT 文件

确定,因为这是原版的Server.dat

@burningtnt
Copy link
Member

burningtnt commented Jan 26, 2024

擦,还真是
那我们怎么判断一个文件有没有 GZIP 过
image
NBT 文件也没 MagicNumber 之类的

@wifi-left
Copy link
Contributor Author

擦,还真是 那我们怎么判断一个文件有没有 GZIP 过

添加 fallback,如果gzip解压出错就直接解析文件。

@burningtnt
Copy link
Member

添加 fallback,如果gzip解压出错就直接解析文件。

有可能存在未压缩的 NBT 文件误打误撞过了 GZIP 解压的可能吗

@wifi-left
Copy link
Contributor Author

NBTExplorer 的逻辑是这么写的。

@wifi-left
Copy link
Contributor Author

添加 fallback,如果gzip解压出错就直接解析文件。

有可能存在未压缩的 NBT 文件误打误撞过了 GZIP 解压的可能吗

概率极小,如果过了那NBTEXPLORER也会出错

@wifi-left
Copy link
Contributor Author

image
而且NBT格式的文件貌似也不会以GZIP标识开头

@burningtnt
Copy link
Member

burningtnt commented Jan 26, 2024

NBT 文件第一个字节必然不为大端序的 1F,有解

@burningtnt burningtnt self-assigned this Jan 26, 2024
Glavo added a commit to Glavo/HMCL that referenced this issue Jan 26, 2024
@burningtnt burningtnt assigned Glavo and unassigned burningtnt Jan 26, 2024
@Glavo Glavo closed this as completed in 207b4d0 Jan 26, 2024
Glavo added a commit to burningtnt/HMCL that referenced this issue Oct 17, 2024
Glavo added a commit that referenced this issue Oct 17, 2024
* Update CallerFinder

* Revert "Fix #2687 (#2688)"

This reverts commit 207b4d0.

* update

---------

Co-authored-by: Glavo <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants