Follow up to e3d54e: Same thing for querying for pre-saved entries

This commit is contained in:
David Dworken
2023-09-22 19:59:19 -07:00
parent e3d54e43e8
commit 51ca2578b7
2 changed files with 29 additions and 4 deletions

View File

@@ -206,10 +206,16 @@ func deletePresavedEntries(ctx context.Context, entry *data.HistoryEntry) error
matchingEntryQuery = matchingEntryQuery.Where("command = ?", entry.Command).Session(&gorm.Session{})
// Get the presaved entry since we need it for doing remote deletes
var presavedEntry data.HistoryEntry
res := matchingEntryQuery.Find(&presavedEntry)
if res.Error != nil {
return fmt.Errorf("failed to search for presaved entry for cmd=%#v: %w", entry.Command, res.Error)
presavedEntry, err := lib.RetryingDbFunctionWithResult(func() (data.HistoryEntry, error) {
var presavedEntry data.HistoryEntry
res := matchingEntryQuery.Find(&presavedEntry)
if res.Error != nil {
return presavedEntry, fmt.Errorf("failed to search for presaved entry for cmd=%#v: %w", entry.Command, res.Error)
}
return presavedEntry, nil
})
if err != nil {
return err
}
// Delete presaved entries locally