mirror of
https://github.com/anchore/syft.git
synced 2026-10-31 14:36:33 +01:00
Keep original FileInfo persisted on file.Metadata structs (#1794)
* pull in fileinfo changes from stereoscope #172 Signed-off-by: Alex Goodman <alex.goodman@anchore.com> * fix CLI test assumption about the docker daemon Signed-off-by: Alex Goodman <alex.goodman@anchore.com> --------- Signed-off-by: Alex Goodman <alex.goodman@anchore.com> Signed-off-by: <>
This commit is contained in:
@@ -307,7 +307,7 @@ func (r *directoryIndexer) disallowRevisitingVisitor(path string, _ os.FileInfo,
|
||||
// - link destinations twice, once for the real file and another through the virtual path
|
||||
// - infinite link cycles
|
||||
if indexed, metadata := r.hasBeenIndexed(path); indexed {
|
||||
if metadata.IsDir {
|
||||
if metadata.IsDir() {
|
||||
// signal to walk() that we should skip this directory entirely
|
||||
return fs.SkipDir
|
||||
}
|
||||
|
||||
@@ -196,7 +196,7 @@ func (r directoryResolver) FilesByPath(userPaths ...string) ([]Location, error)
|
||||
}
|
||||
|
||||
// don't consider directories
|
||||
if entry.Metadata.IsDir {
|
||||
if entry.Metadata.IsDir() {
|
||||
continue
|
||||
}
|
||||
|
||||
@@ -238,7 +238,7 @@ func (r directoryResolver) FilesByGlob(patterns ...string) ([]Location, error) {
|
||||
}
|
||||
|
||||
// don't consider directories
|
||||
if entry.Metadata.IsDir {
|
||||
if entry.Metadata.IsDir() {
|
||||
continue
|
||||
}
|
||||
|
||||
|
||||
@@ -949,7 +949,7 @@ func TestDirectoryResolver_FilesContents_errorOnDirRequest(t *testing.T) {
|
||||
for loc := range resolver.AllLocations() {
|
||||
entry, err := resolver.index.Get(loc.ref)
|
||||
require.NoError(t, err)
|
||||
if entry.Metadata.IsDir {
|
||||
if entry.Metadata.IsDir() {
|
||||
dirLoc = &loc
|
||||
break
|
||||
}
|
||||
|
||||
@@ -100,7 +100,7 @@ func (r *imageAllLayersResolver) FilesByPath(paths ...string) ([]Location, error
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("unable to get file metadata for path=%q: %w", ref.RealPath, err)
|
||||
}
|
||||
if metadata.Metadata.IsDir {
|
||||
if metadata.Metadata.IsDir() {
|
||||
continue
|
||||
}
|
||||
}
|
||||
@@ -143,7 +143,7 @@ func (r *imageAllLayersResolver) FilesByGlob(patterns ...string) ([]Location, er
|
||||
return nil, fmt.Errorf("unable to get file metadata for path=%q: %w", result.RequestPath, err)
|
||||
}
|
||||
// don't consider directories
|
||||
if metadata.Metadata.IsDir {
|
||||
if metadata.Metadata.IsDir() {
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
||||
@@ -370,7 +370,7 @@ func TestAllLayersImageResolver_FilesContents_errorOnDirRequest(t *testing.T) {
|
||||
for loc := range resolver.AllLocations() {
|
||||
entry, err := resolver.img.FileCatalog.Get(loc.ref)
|
||||
require.NoError(t, err)
|
||||
if entry.Metadata.IsDir {
|
||||
if entry.Metadata.IsDir() {
|
||||
dirLoc = &loc
|
||||
break
|
||||
}
|
||||
|
||||
@@ -56,7 +56,7 @@ func (r *imageSquashResolver) FilesByPath(paths ...string) ([]Location, error) {
|
||||
return nil, fmt.Errorf("unable to get file metadata for path=%q: %w", ref.RealPath, err)
|
||||
}
|
||||
// don't consider directories
|
||||
if metadata.Metadata.IsDir {
|
||||
if metadata.Metadata.IsDir() {
|
||||
continue
|
||||
}
|
||||
}
|
||||
@@ -103,7 +103,7 @@ func (r *imageSquashResolver) FilesByGlob(patterns ...string) ([]Location, error
|
||||
return nil, fmt.Errorf("unable to get file metadata for path=%q: %w", result.RequestPath, err)
|
||||
}
|
||||
// don't consider directories
|
||||
if metadata.Metadata.IsDir {
|
||||
if metadata.Metadata.IsDir() {
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
||||
@@ -354,7 +354,7 @@ func TestSquashImageResolver_FilesContents_errorOnDirRequest(t *testing.T) {
|
||||
for loc := range resolver.AllLocations() {
|
||||
entry, err := resolver.img.FileCatalog.Get(loc.ref)
|
||||
require.NoError(t, err)
|
||||
if entry.Metadata.IsDir {
|
||||
if entry.Metadata.IsDir() {
|
||||
dirLoc = &loc
|
||||
break
|
||||
}
|
||||
|
||||
@@ -168,11 +168,10 @@ func (r MockResolver) FileMetadataByLocation(l Location) (FileMetadata, error) {
|
||||
}
|
||||
|
||||
return FileMetadata{
|
||||
Mode: info.Mode(),
|
||||
Type: ty,
|
||||
UserID: 0, // not supported
|
||||
GroupID: 0, // not supported
|
||||
Size: info.Size(),
|
||||
FileInfo: info,
|
||||
Type: ty,
|
||||
UserID: 0, // not supported
|
||||
GroupID: 0, // not supported
|
||||
}, nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user