Skip to content

Commit

Permalink
fix: add ErrFileAlreadyExists support
Browse files Browse the repository at this point in the history
  • Loading branch information
GalvinGao committed Nov 22, 2023
1 parent 4f895db commit 2363af1
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions internal/service/drop_report_archive.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,25 @@ func (s *Archive) ArchiveByDate(ctx context.Context, date time.Time) error {
eg := errgroup.Group{}

if err := s.dropReportsArchiver.Prepare(ctx, date); err != nil {
if errors.Is(err, archiver.ErrFileAlreadyExists) {
log.Info().
Str("evt.name", "archive.drop_reports").
Str("realm", RealmDropReports).
Msg("already archived")

return nil
}
return errors.Wrap(err, "failed to prepare drop reports archiver")
}
if err := s.dropReportExtrasArchiver.Prepare(ctx, date); err != nil {
if errors.Is(err, archiver.ErrFileAlreadyExists) {
log.Info().
Str("evt.name", "archive.drop_report_extras").
Str("realm", RealmDropReportExtras).
Msg("already archived")

return nil
}
return errors.Wrap(err, "failed to prepare drop report extras archiver")
}

Expand All @@ -104,9 +120,12 @@ func (s *Archive) ArchiveByDate(ctx context.Context, date time.Time) error {
}

err = eg.Wait()
log.Info().Err(err).Msg("finished archiving")
log.Info().
Str("evt.name", "archive.finished").
Err(err).
Msg("finished archiving")

return nil
return err
}

func (s *Archive) populateDropReportsToArchiver(ctx context.Context, date time.Time) (int, int, error) {
Expand Down

0 comments on commit 2363af1

Please sign in to comment.