Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions drivers/189pc/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,10 @@ type Cloud189File struct {
// StarLabel int64 `json:"starLabel"`
}

func normalizeCloud189Name(name string) string {
return strings.ReplaceAll(name, "\\'", "'")
}

func (c *Cloud189File) CreateTime() time.Time {
return time.Time(c.CreateDate)
}
Expand All @@ -207,6 +211,8 @@ func (c *Cloud189File) GetID() string { return string(c.ID) }
func (c *Cloud189File) GetPath() string { return "" }
func (c *Cloud189File) Thumb() string { return c.Icon.SmallUrl }

func (c *Cloud189File) GetDisplayName() string { return normalizeCloud189Name(c.Name) }

// 文件夹
type Cloud189Folder struct {
ID String `json:"id"`
Expand Down Expand Up @@ -238,6 +244,8 @@ func (c *Cloud189Folder) IsDir() bool { return true }
func (c *Cloud189Folder) GetID() string { return string(c.ID) }
func (c *Cloud189Folder) GetPath() string { return "" }

func (c *Cloud189Folder) GetDisplayName() string { return normalizeCloud189Name(c.Name) }

type Cloud189FilesResp struct {
//ResCode int `json:"res_code"`
//ResMessage string `json:"res_message"`
Expand Down
14 changes: 11 additions & 3 deletions internal/model/obj.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ type ObjUnwrap interface {
Unwrap() Obj
}

type ObjDisplayName interface {
GetDisplayName() string
}

type Obj interface {
GetSize() int64
GetName() string
Expand Down Expand Up @@ -132,13 +136,17 @@ func ExtractFolder(objs []Obj, extractFolder string) {
})
}

func WrapObjName(objs Obj) Obj {
return &ObjWrapName{Name: utils.MappingName(objs.GetName()), Obj: objs}
func WrapObjName(obj Obj) Obj {
name := obj.GetName()
if displayName, ok := obj.(ObjDisplayName); ok {
name = displayName.GetDisplayName()
}
return &ObjWrapName{Name: utils.MappingName(name), Obj: obj}
}

func WrapObjsName(objs []Obj) {
for i := range objs {
objs[i] = &ObjWrapName{Name: utils.MappingName(objs[i].GetName()), Obj: objs[i]}
objs[i] = WrapObjName(objs[i])
}
}

Expand Down