Skip to content

Conversation

@KirCute
Copy link
Member

@KirCute KirCute commented Jan 12, 2026

Description / 描述

修复

  1. beta 版本显示驱动剩余空间时/fs/list会 panic 的问题。
  2. 115open 驱动在总空间大于约 100TiB 后,API 返回的总空间数值会变成浮点数,导致反序列化为 int64 失败。

问题1原因:一个很神奇的问题,简单地说,以下代码会 panic:

type DiskUsage struct {}

func (d DiskUsage) MarshalJSON() ([]byte, error) {
    // 没有这个函数时不会 panic
}

type StorageDetails struct {
    DiskUsage
}

type StorageDetailsWithName struct {
    *StorageDetails
    Name string `json:"name"`
}

func main() {
    _, _ = json.Marshal(&StorageDetailsWithName{
        StorageDetails: nil,
        Name: "",
    })
}

考虑到name字段已无作用,删除了StorageDetailsWithName结构体。

Motivation and Context / 背景

How Has This Been Tested? / 测试

没测

Checklist / 检查清单

  • I have read the CONTRIBUTING document.
    我已阅读 CONTRIBUTING 文档。
  • I have formatted my code with go fmt or prettier.
    我已使用 go fmtprettier 格式化提交的代码。
  • I have added appropriate labels to this PR (or mentioned needed labels in the description if lacking permissions).
    我已为此 PR 添加了适当的标签(如无权限或需要的标签不存在,请在描述中说明,管理员将后续处理)。
  • I have requested review from relevant code authors using the "Request review" feature when applicable.
    我已在适当情况下使用"Request review"功能请求相关代码作者进行审查。
  • I have updated the repository accordingly (If it’s needed).
    我已相应更新了相关仓库(若适用)。

@KirCute KirCute added bug Module: Filesystem File-system operations related issue/PR PR: TIME-SENSITIVE labels Jan 12, 2026
@hhsw2015
Copy link

我昨天遇到了后台样式显示前台那个存储空间显示。会出现 驱动列表显示不出来的情况。必须隐藏显示空间详情 才正常。是不是和这个有关?

@hhsw2015
Copy link

确实是这个问题引起的 刚测试 能正常显示容量信息

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes two critical bugs related to storage details display: a panic in /fs/list when showing storage space in the beta version, and a deserialization failure in the 115open driver when total space exceeds 100TiB (where the API returns floating-point numbers instead of integers).

Changes:

  • Removed StorageDetailsWithName struct to fix panic caused by JSON marshaling of nil embedded pointers
  • Added ParseInt64 utility function to handle both integer and floating-point storage size values from the 115open API
  • Updated receiver type from value to pointer for GetStorageDetails method

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
internal/model/storage.go Removed StorageDetailsWithName wrapper struct, simplified ObjStorageDetails to directly embed *StorageDetails, improved method receiver consistency
server/handles/fsread.go Updated ObjResp.MountDetails field type from *StorageDetailsWithName to *StorageDetails
internal/op/storage.go Simplified ObjStorageDetails initialization by removing nested struct wrapper
drivers/alias/util.go Simplified ObjStorageDetails initialization in root listing
drivers/alias/driver.go Updated storage details assignment to use simplified structure
drivers/115_open/util.go Added ParseInt64 function to handle both int64 and float64 values from API responses
drivers/115_open/driver.go Integrated ParseInt64 for parsing storage space values

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@xrgzs xrgzs merged commit 85c69d8 into OpenListTeam:main Jan 13, 2026
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Module: Filesystem File-system operations related issue/PR PR: TIME-SENSITIVE

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants