Skip to content
This repository was archived by the owner on Mar 27, 2024. It is now read-only.
Closed
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions util/diff_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,21 @@ func DiffFile(image1, image2 *pkgutil.Image, filename string) (*FileNameDiff, er
image1FilePath := filepath.Join(image1.FSPath, filename)
image2FilePath := filepath.Join(image2.FSPath, filename)

// Diff file metadata.
s1, err := os.Stat(image1FilePath)
if err != nil {
return nil, err
}
s2, err := os.Stat(image2FilePath)
if err != nil {
return nil, err
}

if s1.Mode() != s2.Mode() {
description := fmt.Sprintf("%s in image %s had permission bits %s vs in image %s had %s", filename, image1.Source, s1.Mode(), image2.Source, s2.Mode())
return &FileNameDiff{filename, description, ""}, nil
}

//Get contents of files
image1FileContents, err := pkgutil.GetFileContents(image1FilePath)
if err != nil {
Expand Down Expand Up @@ -238,6 +253,10 @@ func GetModifiedEntries(d1, d2 pkgutil.Directory) []string {
logrus.Errorf("Error diffing contents of %s and %s: %s\n", f1path, f2path, err)
continue
}
// Consider the files as different if their metadata differ.
if f1stat.Mode() != f2stat.Mode() {
same = false
}
if !same {
modified = append(modified, f)
}
Expand Down