storage: change logic of `ArtifactExist` method
Given that: * The produced artifact as advertisted in the path should always be a regular file (including the exclusion of symlinks). * The produced artifact should be readable, so any type of error should count as "does not exist". We should use `os.Lstat` to not follow symlinks; return `false` on any error we run in to, or return if the file mode information reports a regular file.
This commit is contained in:
parent
0ae11b6d3f
commit
b7603f9fd3
|
@ -120,12 +120,14 @@ func (s *Storage) RemoveAllButCurrent(artifact sourcev1.Artifact) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
// ArtifactExist returns a boolean indicating whether the artifact file exists in storage
|
||||
// ArtifactExist returns a boolean indicating whether the artifact exists in storage and is a
|
||||
// regular file.
|
||||
func (s *Storage) ArtifactExist(artifact sourcev1.Artifact) bool {
|
||||
if _, err := os.Stat(artifact.Path); os.IsNotExist(err) {
|
||||
fi, err := os.Lstat(artifact.Path)
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
return fi.Mode().IsRegular()
|
||||
}
|
||||
|
||||
// Archive creates a tar.gz to the artifact path from the given dir excluding any VCS specific
|
||||
|
|
Loading…
Reference in New Issue