diff --git a/src/cli/repo/s3.go b/src/cli/repo/s3.go index 2dbf4cb9f..49e1bdac6 100644 --- a/src/cli/repo/s3.go +++ b/src/cli/repo/s3.go @@ -183,7 +183,7 @@ func connectS3Cmd(cmd *cobra.Command, args []string) error { return Only(ctx, errors.Wrap(err, "Failed to parse m365 account config")) } - r, err := repository.Connect(ctx, a, s, options.Control()) + r, err := repository.ConnectAndSendConnectEvent(ctx, a, s, options.Control()) if err != nil { return Only(ctx, errors.Wrap(err, "Failed to connect to the S3 repository")) } diff --git a/src/pkg/repository/repository.go b/src/pkg/repository/repository.go index da715f61e..ab4e05733 100644 --- a/src/pkg/repository/repository.go +++ b/src/pkg/repository/repository.go @@ -216,6 +216,22 @@ func Connect( }, nil } +func ConnectAndSendConnectEvent(ctx context.Context, + acct account.Account, + s storage.Storage, + opts control.Options, +) (Repository, error) { + repo, err := Connect(ctx, acct, s, opts) + + r := repo.(*repository) + + if err == nil { + r.Bus.Event(ctx, events.RepoConnect, nil) + } + + return r, err +} + func (r *repository) Close(ctx context.Context) error { if err := r.Bus.Close(); err != nil { logger.Ctx(ctx).With("err", err).Debugw("closing the event bus", clues.In(ctx).Slice()...)