Skip to content

Commit

Permalink
fix static check error in vfssync.go
Browse files Browse the repository at this point in the history
  • Loading branch information
Guangming Wang committed Aug 28, 2019
1 parent a957428 commit d36a1f7
Showing 1 changed file with 16 additions and 17 deletions.
33 changes: 16 additions & 17 deletions util/pkg/vfs/vfssync.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ type Change struct {
func (v *VFSScan) Scan() ([]Change, error) {
allFiles, err := v.Base.ReadTree()
if err != nil {
return nil, fmt.Errorf("Error reading dir %q: %v", v.Base, err)
return nil, fmt.Errorf("error reading dir %q: %v", v.Base, err)
}

files := make(map[string]Path)
Expand All @@ -64,11 +64,11 @@ func (v *VFSScan) Scan() ([]Change, error) {
files[key] = f
hasHash, ok := f.(HasHash)
if !ok {
return nil, fmt.Errorf("Source must support hashing: %T", f)
return nil, fmt.Errorf("source must support hashing: %T", f)
}
hash, err := hasHash.PreferredHash()
if err != nil {
return nil, fmt.Errorf("Error hashing %q: %v", key, err)
return nil, fmt.Errorf("error hashing %q: %v", key, err)
}

hashes[key] = hash
Expand Down Expand Up @@ -111,7 +111,7 @@ func (v *VFSScan) Scan() ([]Change, error) {
func SyncDir(src *VFSScan, destBase Path) error {
changes, err := src.Scan()
if err != nil {
return fmt.Errorf("Error scanning source dir %q: %v", src, err)
return fmt.Errorf("error scanning source dir %q: %v", src, err)
}

for _, change := range changes {
Expand All @@ -135,24 +135,23 @@ func SyncDir(src *VFSScan, destBase Path) error {
continue

case ChangeType_Modified, ChangeType_Added:
break
hashMatch, err := hashesMatch(f, destFile)
if err != nil {
return err
}
if hashMatch {
klog.V(2).Infof("File hashes match: %s and %s", f, destFile)
continue
}

if err := CopyFile(f, destFile, nil); err != nil {
return err
}

default:
return fmt.Errorf("unknown change type: %q", change.ChangeType)
}

hashMatch, err := hashesMatch(f, destFile)
if err != nil {
return err
}
if hashMatch {
klog.V(2).Infof("File hashes match: %s and %s", f, destFile)
continue
}

if err := CopyFile(f, destFile, nil); err != nil {
return err
}
}

return nil
Expand Down

0 comments on commit d36a1f7

Please sign in to comment.