Skip to content

Commit c73e4ed

Browse files
engine-manager: let modelStore.under answer for non-directories itself
Only a real directory can lead to the model store, so under now returns false for anything else rather than relying on its caller to check first. Signed-off-by: Terve <ntervalon@nvidia.com>
1 parent 1ceb4b1 commit c73e4ed

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

‎services/nvpair-engine-manager/removepath.go‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ func removeTreePreserving(target, preserve string) error {
9696
switch {
9797
case store.is(childInfo):
9898
// The store, by the name it was given or the directory it leads to.
99-
case childInfo.IsDir() && store.under(childInfo):
99+
case store.under(childInfo):
100100
// On the way to the store. Recurse so siblings deeper down still go.
101101
if err := removeTreePreserving(child, absPreserve); err != nil {
102102
failures = append(failures, err)
@@ -142,8 +142,12 @@ func (s modelStore) is(fi os.FileInfo) bool {
142142
return false
143143
}
144144

145-
// under reports whether fi is a directory the store sits below.
145+
// under reports whether fi is a directory the store sits below. Anything else,
146+
// a link to one included, is not: removal descends only into real directories.
146147
func (s modelStore) under(fi os.FileInfo) bool {
148+
if !fi.IsDir() {
149+
return false
150+
}
147151
for _, dir := range s.above {
148152
if os.SameFile(fi, dir) {
149153
return true

0 commit comments

Comments
 (0)