From 991ee424ea8f5013a1598e3234c8a299b1b6b353 Mon Sep 17 00:00:00 2001 From: "a624669980@163.com" Date: Fri, 19 Aug 2022 13:48:52 +0800 Subject: [PATCH] update usb show name --- route/v1/disk.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/route/v1/disk.go b/route/v1/disk.go index 271c9b5..7601eb4 100644 --- a/route/v1/disk.go +++ b/route/v1/disk.go @@ -3,6 +3,7 @@ package v1 import ( "fmt" "net/http" + "path/filepath" "reflect" "strconv" "strings" @@ -210,6 +211,9 @@ func GetDisksUSBList(c *gin.Context) { tempChildren.Size, _ = strconv.ParseUint(child.FSSize, 10, 64) tempChildren.Avail, _ = strconv.ParseUint(child.FSAvail, 10, 64) tempChildren.Name = child.Label + if len(tempChildren.Name) == 0 { + tempChildren.Name = filepath.Base(child.MountPoint) + } avail, _ := strconv.ParseUint(child.FSAvail, 10, 64) children = append(children, tempChildren) temp.Avail += avail