mirror of
https://github.com/mxpv/podsync.git
synced 2024-05-11 05:55:04 +00:00
Save cache even if DynamoDB request failed
This commit is contained in:
@ -177,7 +177,7 @@ func (s *Service) BuildFeed(hashID string) ([]byte, error) {
|
||||
logger.WithError(err).Error("failed to build feed")
|
||||
|
||||
// Save error to cache to avoid spamming
|
||||
_ = s.cache.Set(hashID, err.Error(), 10 * time.Minute)
|
||||
_ = s.cache.Set(hashID, err.Error(), 10*time.Minute)
|
||||
|
||||
return nil, err
|
||||
}
|
||||
@ -189,13 +189,6 @@ func (s *Service) BuildFeed(hashID string) ([]byte, error) {
|
||||
}
|
||||
}
|
||||
|
||||
if oldCount != len(feed.Episodes) {
|
||||
if err := s.storage.UpdateFeed(feed); err != nil {
|
||||
logger.WithError(err).Error("failed to save feed")
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
// Format podcast
|
||||
|
||||
podcast, err := s.buildPodcast(feed)
|
||||
@ -212,6 +205,14 @@ func (s *Service) BuildFeed(hashID string) ([]byte, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// Save to database
|
||||
|
||||
if oldCount != len(feed.Episodes) {
|
||||
if err := s.storage.UpdateFeed(feed); err != nil {
|
||||
logger.WithError(err).Error("failed to save feed")
|
||||
}
|
||||
}
|
||||
|
||||
return []byte(body), nil
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user