mirror of
https://github.com/linuxkit/linuxkit.git
synced 2025-07-22 10:31:35 +00:00
Merge pull request #3821 from giggsoff/do-not-calculate-broken-symlinks
Skip files in contentHash()
This commit is contained in:
commit
7c4e89b652
@ -94,9 +94,20 @@ func (g git) contentHash() (string, error) {
|
||||
}
|
||||
scanner := bufio.NewScanner(strings.NewReader(strings.TrimSpace(out)))
|
||||
for scanner.Scan() {
|
||||
f, err := os.Open(filepath.Join(g.dir, scanner.Text()))
|
||||
filename := filepath.Join(g.dir, scanner.Text())
|
||||
info, err := os.Lstat(filename)
|
||||
if err != nil {
|
||||
return "", err
|
||||
log.Debugf("cannot stat %s: %s, skipped", filename, err)
|
||||
continue
|
||||
}
|
||||
if info.IsDir() || info.Mode()&os.ModeSymlink != 0 {
|
||||
// we do not want to calculate hash of directory or symlinks
|
||||
continue
|
||||
}
|
||||
f, err := os.Open(filename)
|
||||
if err != nil {
|
||||
log.Debugf("cannot open %s: %s, skipped", filename, err)
|
||||
continue
|
||||
}
|
||||
if _, err := io.Copy(hash, f); err != nil {
|
||||
_ = f.Close()
|
||||
|
Loading…
Reference in New Issue
Block a user