(group *models.Group, keys []string)
| 49 | } |
| 50 | |
| 51 | func (s *KeyDeleteService) runDelete(group *models.Group, keys []string) { |
| 52 | progressCallback := func(processed int) { |
| 53 | if err := s.TaskService.UpdateProgress(processed); err != nil { |
| 54 | logrus.Warnf("Failed to update task progress for group %d: %v", group.ID, err) |
| 55 | } |
| 56 | } |
| 57 | |
| 58 | deletedCount, ignoredCount, err := s.processAndDeleteKeys(group.ID, keys, progressCallback) |
| 59 | if err != nil { |
| 60 | if endErr := s.TaskService.EndTask(nil, err); endErr != nil { |
| 61 | logrus.Errorf("Failed to end task with error for group %d: %v (original error: %v)", group.ID, endErr, err) |
| 62 | } |
| 63 | return |
| 64 | } |
| 65 | |
| 66 | result := KeyDeleteResult{ |
| 67 | DeletedCount: deletedCount, |
| 68 | IgnoredCount: ignoredCount, |
| 69 | } |
| 70 | |
| 71 | if endErr := s.TaskService.EndTask(result, nil); endErr != nil { |
| 72 | logrus.Errorf("Failed to end task with success result for group %d: %v", group.ID, endErr) |
| 73 | } |
| 74 | } |
| 75 | |
| 76 | // processAndDeleteKeys is the core function for deleting keys with progress tracking. |
| 77 | func (s *KeyDeleteService) processAndDeleteKeys( |
no test coverage detected