fix: delete folders using postorder (#113493)

* fix: delete folders using postorder

* chore: use helper function and do not add method to Folder store

- addresses other review comments fixing log messages and cleans up the unit tests

* chore: run library element tests on modes 2,3,5 only

* chore: adjust to folder.SortByPostorder(folders []*Folder)

* chore: run library panels tests in mode 2,3,5 only

* chore: run tests in all modes and increase timeout

- adjusting the modes and tweaking configs will be done separately
This commit is contained in:
Rafael Bortolon Paulovic
2025-11-06 15:04:34 +01:00
committed by GitHub
parent fbf1cdd0ce
commit e69f3c55f7
8 changed files with 314 additions and 8 deletions
@@ -618,12 +618,14 @@ func (s *Service) deleteFromApiServer(ctx context.Context, cmd *folder.DeleteFol
if err != nil {
return err
}
descFolders = folder.SortByPostorder(descFolders)
folders := []string{}
for _, f := range descFolders {
folders = append(folders, f.UID)
}
// must delete children first, then the parent folder
s.log.InfoContext(ctx, "deleting folder with descendants", "org_id", cmd.OrgID, "uid", cmd.UID, "folderUIDs", strings.Join(folders, ","))
folders = append(folders, cmd.UID)
if cmd.ForceDeleteRules {