Skip to content
Merged
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
4 changes: 2 additions & 2 deletions drivers/115_open/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -331,11 +331,11 @@ func (d *Open115) GetDetails(ctx context.Context) (*model.StorageDetails, error)
if err != nil {
return nil, err
}
total, err := userInfo.RtSpaceInfo.AllTotal.Size.Int64()
total, err := ParseInt64(userInfo.RtSpaceInfo.AllTotal.Size)
if err != nil {
return nil, err
}
used, err := userInfo.RtSpaceInfo.AllUse.Size.Int64()
used, err := ParseInt64(userInfo.RtSpaceInfo.AllUse.Size)
if err != nil {
return nil, err
}
Expand Down
14 changes: 13 additions & 1 deletion drivers/115_open/util.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
package _115_open

// do others that not defined in Driver interface
import "encoding/json"

func ParseInt64(v json.Number) (int64, error) {
i, err := v.Int64()
if err == nil {
return i, nil
}
f, e1 := v.Float64()
if e1 == nil {
return int64(f), nil
}
return int64(0), err
}
4 changes: 2 additions & 2 deletions drivers/alias/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -218,8 +218,8 @@ func (d *Alias) List(ctx context.Context, dir model.Obj, args model.ListArgs) ([
}
if details, ok := model.GetStorageDetails(obj); ok {
objRet = &model.ObjStorageDetails{
Obj: objRet,
StorageDetailsWithName: *details,
Obj: objRet,
StorageDetails: details,
}
}
objMap[name] = objRet
Expand Down
7 changes: 2 additions & 5 deletions drivers/alias/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,8 @@ func (d *Alias) listRoot(ctx context.Context, withDetails, refresh bool) []model
continue
}
objs[idx] = &model.ObjStorageDetails{
Obj: objs[idx],
StorageDetailsWithName: model.StorageDetailsWithName{
StorageDetails: nil,
DriverName: remoteDriver.Config().Name,
},
Obj: objs[idx],
StorageDetails: nil,
}
workerCount++
go func(dri driver.Driver, i int) {
Expand Down
15 changes: 5 additions & 10 deletions internal/model/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,29 +79,24 @@ type StorageDetails struct {
DiskUsage
}

type StorageDetailsWithName struct {
*StorageDetails
DriverName string `json:"driver_name"`
}

type ObjWithStorageDetails interface {
GetStorageDetails() *StorageDetailsWithName
GetStorageDetails() *StorageDetails
}

type ObjStorageDetails struct {
Obj
StorageDetailsWithName
*StorageDetails
}

func (o *ObjStorageDetails) Unwrap() Obj {
return o.Obj
}

func (o ObjStorageDetails) GetStorageDetails() *StorageDetailsWithName {
return &o.StorageDetailsWithName
func (o *ObjStorageDetails) GetStorageDetails() *StorageDetails {
return o.StorageDetails
}

func GetStorageDetails(obj Obj) (*StorageDetailsWithName, bool) {
func GetStorageDetails(obj Obj) (*StorageDetails, bool) {
if obj, ok := obj.(ObjWithStorageDetails); ok {
return obj.GetStorageDetails(), true
}
Expand Down
7 changes: 2 additions & 5 deletions internal/op/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -353,11 +353,8 @@ func GetStorageVirtualFilesWithDetailsByPath(ctx context.Context, prefix string,
return obj
}
ret := &model.ObjStorageDetails{
Obj: obj,
StorageDetailsWithName: model.StorageDetailsWithName{
StorageDetails: nil,
DriverName: d.Config().Name,
},
Obj: obj,
StorageDetails: nil,
}
resultChan := make(chan *model.StorageDetails, 1)
go func(dri driver.Driver) {
Expand Down
22 changes: 11 additions & 11 deletions server/handles/fsread.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,17 @@ type DirReq struct {
}

type ObjResp struct {
Name string `json:"name"`
Size int64 `json:"size"`
IsDir bool `json:"is_dir"`
Modified time.Time `json:"modified"`
Created time.Time `json:"created"`
Sign string `json:"sign"`
Thumb string `json:"thumb"`
Type int `json:"type"`
HashInfoStr string `json:"hashinfo"`
HashInfo map[*utils.HashType]string `json:"hash_info"`
MountDetails *model.StorageDetailsWithName `json:"mount_details,omitempty"`
Name string `json:"name"`
Size int64 `json:"size"`
IsDir bool `json:"is_dir"`
Modified time.Time `json:"modified"`
Created time.Time `json:"created"`
Sign string `json:"sign"`
Thumb string `json:"thumb"`
Type int `json:"type"`
HashInfoStr string `json:"hashinfo"`
HashInfo map[*utils.HashType]string `json:"hash_info"`
MountDetails *model.StorageDetails `json:"mount_details,omitempty"`
}

type FsListResp struct {
Expand Down
Loading