Possible fix for stat error during globbing

Globs can fail when a directory is replaced with a file:
Error checking globs: stat foo: not a directory

Manually check for syscall.ENOTDIR, which is not covered by
fs.ErrNotExist.


Ignore-AOSP-First: "Landing internal first for critical ap4a move"
Bug: 369548825
Test: manual
Flag: EXEMPT bugfix
(cherry picked from https://googleplex-android-review.googlesource.com/q/commit:c3cd8e3f3c93773f0051608b94a0358554a95c98)
Merged-In: I35f65725b70fc0abb22aff46298d053d98d03b00
Change-Id: I35f65725b70fc0abb22aff46298d053d98d03b00
This commit is contained in:
Colin Cross
2024-09-25 09:14:21 -07:00
committed by Android Build Coastguard Worker
parent cf886f91e4
commit de7d7bcab2

View File

@@ -27,6 +27,7 @@ import (
"strings" "strings"
"sync" "sync"
"sync/atomic" "sync/atomic"
"syscall"
"time" "time"
"android/soong/ui/tracer" "android/soong/ui/tracer"
@@ -780,7 +781,7 @@ func checkGlobs(ctx Context, finalOutFile string) error {
hasNewDep := false hasNewDep := false
for _, dep := range cachedGlob.Deps { for _, dep := range cachedGlob.Deps {
info, err := os.Stat(dep) info, err := os.Stat(dep)
if errors.Is(err, fs.ErrNotExist) { if errors.Is(err, fs.ErrNotExist) || errors.Is(err, syscall.ENOTDIR) {
hasNewDep = true hasNewDep = true
break break
} else if err != nil { } else if err != nil {