Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix static check error in vfssync.go #7482

Merged
merged 1 commit into from
Sep 7, 2019
Merged
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
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