Skip to content
This repository has been archived by the owner on Aug 13, 2019. It is now read-only.

Commit

Permalink
nit
Browse files Browse the repository at this point in the history
Signed-off-by: Krasi Georgiev <8903888+krasi-georgiev@users.noreply.github.com>
  • Loading branch information
krasi-georgiev committed Jun 25, 2019
1 parent bd79d07 commit 106d0e9
Showing 1 changed file with 27 additions and 25 deletions.
52 changes: 27 additions & 25 deletions testutil/directory.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,33 +154,35 @@ func DirHash(path string) ([]byte, error) {
if err != nil {
return err
}
if !info.IsDir() {
f, err := os.Open(path)
if err != nil {
return err
}
defer f.Close()

if _, err := io.Copy(hash, f); err != nil {
return err
}

if _, err := io.WriteString(hash, strconv.Itoa(int(info.Size()))); err != nil {
return err
}
if _, err := io.WriteString(hash, info.Name()); err != nil {
return err
}
modTime, err := info.ModTime().GobEncode()
if err != nil {
return err
}
if _, err := io.WriteString(hash, string(modTime)); err != nil {
return err
}
if info.IsDir() {
return nil
}
f, err := os.Open(path)
if err != nil {
return err
}
defer f.Close()

if _, err := io.Copy(hash, f); err != nil {
return err
}
return err

if _, err := io.WriteString(hash, strconv.Itoa(int(info.Size()))); err != nil {
return err
}
if _, err := io.WriteString(hash, info.Name()); err != nil {
return err
}
modTime, err := info.ModTime().GobEncode()
if err != nil {
return err
}
if _, err := io.WriteString(hash, string(modTime)); err != nil {
return err
}

return nil
})

return hash.Sum(nil), err
}

0 comments on commit 106d0e9

Please sign in to comment.