Skip to content

Commit

Permalink
chore: more logging on version upload
Browse files Browse the repository at this point in the history
  • Loading branch information
Vilsol committed Dec 6, 2021
1 parent f2cf2fe commit 96b28e8
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
6 changes: 6 additions & 0 deletions gql/resolver_versions.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ func (r *mutationResolver) FinalizeCreateVersion(ctx context.Context, modID stri
return false, errors.New("you must update your mod reference on the site to match your mod_reference in your data.json")
}

log.Ctx(ctx).Info().Str("mod_id", mod.ID).Str("version_id", versionID).Msg("finalization gql call")

go func(ctx context.Context, mod *postgres.Mod, versionID string, version generated.NewVersion) {
defer func() {
if r := recover(); r != nil {
Expand All @@ -111,12 +113,16 @@ func (r *mutationResolver) FinalizeCreateVersion(ctx context.Context, modID stri
}
}()

log.Ctx(ctx).Info().Str("mod_id", mod.ID).Str("version_id", versionID).Msg("calling FinalizeVersionUploadAsync")

data, err := FinalizeVersionUploadAsync(ctx, mod, versionID, version)
if err2 := redis.StoreVersionUploadState(versionID, data, err); err2 != nil {
log.Ctx(ctx).Err(err2).Msg("error storing redis state")
return
}

log.Ctx(ctx).Info().Str("mod_id", mod.ID).Str("version_id", versionID).Msg("finished FinalizeVersionUploadAsync")

if err != nil {
log.Ctx(ctx).Err(err).Msgf("error completing version upload [%s]", versionID)
} else {
Expand Down
4 changes: 4 additions & 0 deletions gql/versions.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ import (
)

func FinalizeVersionUploadAsync(ctx context.Context, mod *postgres.Mod, versionID string, version generated.NewVersion) (*generated.CreateVersionResponse, error) {
l := log.With().Str("mod_id", mod.ID).Str("version_id", versionID).Logger()

l.Info().Msg("Creating multipart upload")
success, _ := storage.CompleteUploadMultipartMod(ctx, mod.ID, mod.Name, versionID)

if !success {
Expand Down Expand Up @@ -163,6 +166,7 @@ func FinalizeVersionUploadAsync(ctx context.Context, mod *postgres.Mod, versionI

go integrations.NewVersion(util.ReWrapCtx(ctx), dbVersion)
} else {
l.Info().Msg("Submitting version job for virus scan")
jobs.SubmitJobScanModOnVirusTotalTask(ctx, mod.ID, dbVersion.ID, true)
}

Expand Down
3 changes: 3 additions & 0 deletions integrations/discord.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"io"
"io/ioutil"
"net/http"
"runtime/debug"
"strings"

"github.com/satisfactorymodding/smr-api/db/postgres"
Expand Down Expand Up @@ -79,6 +80,8 @@ func NewMod(ctx context.Context, mod *postgres.Mod) {
}

func NewVersion(ctx context.Context, version *postgres.Version) {
log.Ctx(ctx).Info().Str("stack", string(debug.Stack())).Msg("new version discord webhook")

if version == nil {
return
}
Expand Down

0 comments on commit 96b28e8

Please sign in to comment.