Skip to content
This repository has been archived by the owner on Dec 20, 2024. It is now read-only.

Commit

Permalink
supernode: cleanup code based on static check warning
Browse files Browse the repository at this point in the history
Signed-off-by: hwdef <[email protected]>
  • Loading branch information
hwdef committed Sep 27, 2019
1 parent 71d3b08 commit e08e1a2
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 10 deletions.
2 changes: 1 addition & 1 deletion pkg/util/assert.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func IsNil(value interface{}) bool {

// IsTrue returns whether the value is true.
func IsTrue(value bool) bool {
return value == true
return value
}

// IsPositive returns whether the value is a positive number.
Expand Down
10 changes: 3 additions & 7 deletions supernode/daemon/mgr/cdn/cdn_gc.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func (cm *Manager) GetGCTaskIDs(ctx context.Context, taskMgr mgr.TaskMgr) ([]str

// walkTaskIDs is used to avoid processing multiple times for the same taskID
// which is extracted from file name.
walkTaskIDs := make(map[string]bool, 0)
walkTaskIDs := make(map[string]bool)
walkFn := func(path string, info os.FileInfo, err error) error {
logrus.Debugf("start to walk path(%s)", path)

Expand Down Expand Up @@ -155,17 +155,13 @@ func getGCTasks(gapTasks, intervalTasks *treemap.Map) []string {

for _, v := range gapTasks.Values() {
if taskIDs, ok := v.([]string); ok {
for _, taskID := range taskIDs {
gcTasks = append(gcTasks, taskID)
}
gcTasks = append(gcTasks, taskIDs...)
}
}

for _, v := range intervalTasks.Values() {
if taskIDs, ok := v.([]string); ok {
for _, taskID := range taskIDs {
gcTasks = append(gcTasks, taskID)
}
gcTasks = append(gcTasks, taskIDs...)
}
}

Expand Down
2 changes: 1 addition & 1 deletion supernode/daemon/mgr/cdn/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ func (cm *Manager) TriggerCDN(ctx context.Context, task *types.TaskInfo) (*types

realMD5 := reader.Md5()
success, err := cm.handleCDNResult(ctx, task, realMD5, httpFileLength, downloadMetadata.realHTTPFileLength, downloadMetadata.realFileLength)
if err != nil || success == false {
if err != nil || !success {
return getUpdateTaskInfoWithStatusOnly(types.TaskInfoCdnStatusFAILED), err
}

Expand Down
2 changes: 1 addition & 1 deletion supernode/daemon/mgr/cdn/reporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func (re *reporter) reportCache(ctx context.Context, taskID string, metaData *fi
}

success, updateTaskInfo, err := re.processCacheByQuick(ctx, taskID, metaData, breakNum)
if err == nil && success == true {
if err == nil && success {
// it is possible to succeed only if breakNum equals -1
return nil, updateTaskInfo, nil
}
Expand Down

0 comments on commit e08e1a2

Please sign in to comment.