Skip to content

Commit affc499

Browse files
authored
fix(189): disk-usage unmarshal failed when used capacity overflow (#1577)
1 parent c7574b5 commit affc499

File tree

6 files changed

+15
-24
lines changed

6 files changed

+15
-24
lines changed

drivers/189/driver.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -200,10 +200,7 @@ func (d *Cloud189) GetDetails(ctx context.Context) (*model.StorageDetails, error
200200
return nil, err
201201
}
202202
return &model.StorageDetails{
203-
DiskUsage: model.DiskUsage{
204-
TotalSpace: capacityInfo.CloudCapacityInfo.TotalSize,
205-
FreeSpace: capacityInfo.CloudCapacityInfo.FreeSize,
206-
},
203+
DiskUsage: driver.DiskUsageFromUsedAndTotal(capacityInfo.CloudCapacityInfo.UsedSize, capacityInfo.CloudCapacityInfo.TotalSize),
207204
}, nil
208205
}
209206

drivers/189/types.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,13 +72,13 @@ type CapacityResp struct {
7272
ResMessage string `json:"res_message"`
7373
Account string `json:"account"`
7474
CloudCapacityInfo struct {
75-
FreeSize uint64 `json:"freeSize"`
75+
FreeSize int64 `json:"freeSize"`
7676
MailUsedSize uint64 `json:"mail189UsedSize"`
7777
TotalSize uint64 `json:"totalSize"`
7878
UsedSize uint64 `json:"usedSize"`
7979
} `json:"cloudCapacityInfo"`
8080
FamilyCapacityInfo struct {
81-
FreeSize uint64 `json:"freeSize"`
81+
FreeSize int64 `json:"freeSize"`
8282
TotalSize uint64 `json:"totalSize"`
8383
UsedSize uint64 `json:"usedSize"`
8484
} `json:"familyCapacityInfo"`

drivers/189_tv/driver.go

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -284,18 +284,15 @@ func (y *Cloud189TV) GetDetails(ctx context.Context) (*model.StorageDetails, err
284284
if err != nil {
285285
return nil, err
286286
}
287-
var total, free uint64
287+
var total, used uint64
288288
if y.isFamily() {
289289
total = capacityInfo.FamilyCapacityInfo.TotalSize
290-
free = capacityInfo.FamilyCapacityInfo.FreeSize
290+
used = capacityInfo.FamilyCapacityInfo.UsedSize
291291
} else {
292292
total = capacityInfo.CloudCapacityInfo.TotalSize
293-
free = capacityInfo.CloudCapacityInfo.FreeSize
293+
used = capacityInfo.CloudCapacityInfo.UsedSize
294294
}
295295
return &model.StorageDetails{
296-
DiskUsage: model.DiskUsage{
297-
TotalSpace: total,
298-
FreeSpace: free,
299-
},
296+
DiskUsage: driver.DiskUsageFromUsedAndTotal(used, total),
300297
}, nil
301298
}

drivers/189_tv/types.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -322,13 +322,13 @@ type CapacityResp struct {
322322
ResMessage string `json:"res_message"`
323323
Account string `json:"account"`
324324
CloudCapacityInfo struct {
325-
FreeSize uint64 `json:"freeSize"`
325+
FreeSize int64 `json:"freeSize"`
326326
MailUsedSize uint64 `json:"mail189UsedSize"`
327327
TotalSize uint64 `json:"totalSize"`
328328
UsedSize uint64 `json:"usedSize"`
329329
} `json:"cloudCapacityInfo"`
330330
FamilyCapacityInfo struct {
331-
FreeSize uint64 `json:"freeSize"`
331+
FreeSize int64 `json:"freeSize"`
332332
TotalSize uint64 `json:"totalSize"`
333333
UsedSize uint64 `json:"usedSize"`
334334
} `json:"familyCapacityInfo"`

drivers/189pc/driver.go

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -416,18 +416,15 @@ func (y *Cloud189PC) GetDetails(ctx context.Context) (*model.StorageDetails, err
416416
if err != nil {
417417
return nil, err
418418
}
419-
var total, free uint64
419+
var total, used uint64
420420
if y.isFamily() {
421421
total = capacityInfo.FamilyCapacityInfo.TotalSize
422-
free = capacityInfo.FamilyCapacityInfo.FreeSize
422+
used = capacityInfo.FamilyCapacityInfo.UsedSize
423423
} else {
424424
total = capacityInfo.CloudCapacityInfo.TotalSize
425-
free = capacityInfo.CloudCapacityInfo.FreeSize
425+
used = capacityInfo.CloudCapacityInfo.UsedSize
426426
}
427427
return &model.StorageDetails{
428-
DiskUsage: model.DiskUsage{
429-
TotalSpace: total,
430-
FreeSpace: free,
431-
},
428+
DiskUsage: driver.DiskUsageFromUsedAndTotal(used, total),
432429
}, nil
433430
}

drivers/189pc/types.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -415,13 +415,13 @@ type CapacityResp struct {
415415
ResMessage string `json:"res_message"`
416416
Account string `json:"account"`
417417
CloudCapacityInfo struct {
418-
FreeSize uint64 `json:"freeSize"`
418+
FreeSize int64 `json:"freeSize"`
419419
MailUsedSize uint64 `json:"mail189UsedSize"`
420420
TotalSize uint64 `json:"totalSize"`
421421
UsedSize uint64 `json:"usedSize"`
422422
} `json:"cloudCapacityInfo"`
423423
FamilyCapacityInfo struct {
424-
FreeSize uint64 `json:"freeSize"`
424+
FreeSize int64 `json:"freeSize"`
425425
TotalSize uint64 `json:"totalSize"`
426426
UsedSize uint64 `json:"usedSize"`
427427
} `json:"familyCapacityInfo"`

0 commit comments

Comments
 (0)