fix: 系统信息读取磁盘获取超时导致返回空数组
This commit is contained in:
@@ -152,11 +152,11 @@ func (s *SystemInfoImpl) NetworkInfo() map[string]string {
|
||||
func (s *SystemInfoImpl) DiskInfo() []map[string]string {
|
||||
disks := make([]map[string]string, 0)
|
||||
ctx := context.Background()
|
||||
ctx, cancel := context.WithTimeout(ctx, 1*time.Second)
|
||||
ctx, cancel := context.WithTimeout(ctx, 2*time.Second)
|
||||
defer cancel()
|
||||
|
||||
partitions, err := disk.PartitionsWithContext(ctx, false)
|
||||
if err != context.DeadlineExceeded {
|
||||
if err != nil && err != context.DeadlineExceeded {
|
||||
return disks
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user