@@ -205,17 +205,20 @@ func maxHistoryAge(desc *Description) time.Duration {
205205 return DefaultMaxHistoryAge
206206}
207207
208- func getDescriptionFile [T any ](name string , get func (string ) (T , error )) (T , string , bool , error ) {
209- isParent := false
208+ func getDescriptionFile [T any ](name string , allowSubgroups bool , get func (string ) (T , error )) (T , string , bool , error ) {
209+ isSubgroup := false
210210 for name != "" {
211211 fileName := filepath .Join (
212212 Directory , path .Clean ("/" + name )+ ".json" ,
213213 )
214214 r , err := get (fileName )
215215 if ! os .IsNotExist (err ) {
216- return r , fileName , isParent , err
216+ return r , fileName , isSubgroup , err
217217 }
218- isParent = true
218+ if ! allowSubgroups {
219+ break
220+ }
221+ isSubgroup = true
219222 name , _ = path .Split (name )
220223 name = strings .TrimRight (name , "/" )
221224 }
@@ -239,7 +242,7 @@ func descriptionMatch(d1, d2 *Description) bool {
239242// descriptionUnchanged returns true if a group's description hasn't
240243// changed since it was last read.
241244func descriptionUnchanged (name string , desc * Description ) bool {
242- fi , fileName , _ , err := getDescriptionFile (name , os .Stat )
245+ fi , fileName , _ , err := getDescriptionFile (name , true , os .Stat )
243246 if err != nil || fileName != desc .FileName {
244247 return false
245248 }
@@ -259,12 +262,13 @@ func GetDescription(name string) (*Description, error) {
259262 }
260263 }
261264
262- return readDescription (name )
265+ return readDescription (name , true )
263266}
264267
265268// readDescription reads a group's description from disk
266- func readDescription (name string ) (* Description , error ) {
267- r , fileName , isParent , err := getDescriptionFile (name , os .Open )
269+ func readDescription (name string , allowSubgroups bool ) (* Description , error ) {
270+ r , fileName , isSubgroup , err :=
271+ getDescriptionFile (name , allowSubgroups , os .Open )
268272 if err != nil {
269273 return nil , err
270274 }
@@ -283,7 +287,7 @@ func readDescription(name string) (*Description, error) {
283287 if err != nil {
284288 return nil , err
285289 }
286- if isParent {
290+ if isSubgroup {
287291 if ! desc .AutoSubgroups {
288292 return nil , os .ErrNotExist
289293 }
0 commit comments