Change more stuff

styling-fixes
Pancakes 2 months ago
parent 00e783ff8a
commit c09d277678
No known key found for this signature in database
GPG Key ID: 5792877BFA27DC8F

@ -91,17 +91,14 @@ func Init() error {
scheduler.Start()
if os.Getenv("AWS_ENDPOINT_URL_S3") == "" {
log.Printf("AWS_ENDPOINT_URL_S3 not set, skipping s3 migration")
return nil
}
if os.Getenv("AWS_ENDPOINT_URL_S3") != "" {
_, err = s3scheduler.AddFunc("@hourly", S3SaveMigration)
if err != nil {
return err
}
s3scheduler.Start()
}
return nil
}
@ -162,15 +159,16 @@ func S3SaveMigration() {
Body: bytes.NewReader(json),
})
if err != nil {
log.Printf("error while saving data in s3 for user %s: %s", username, err)
log.Printf("error while saving data in S3 for user %s: %s", username, err)
continue
}
err = db.UpdateLocation(user, username)
if err != nil {
log.Printf("Failed to update location for user %s: %s", username, err)
continue
}
fmt.Printf("Saved data in s3 for user %s\n", username)
log.Printf("Saved data in S3 for user %s", username)
}
}

@ -420,8 +420,7 @@ func handleSystem(w http.ResponseWriter, r *http.Request) {
if errors.Is(err, sql.ErrNoRows) {
http.Error(w, err.Error(), http.StatusNotFound)
} else {
fmt.Printf("failed to get system save data: %s\n", err)
httpError(w, r, err, http.StatusInternalServerError)
httpError(w, r, fmt.Errorf("failed to get system save data: %s", err), http.StatusInternalServerError)
}
return

@ -22,7 +22,7 @@ import (
"context"
"encoding/gob"
"encoding/json"
"fmt"
"log"
"github.com/klauspost/compress/zstd"
"github.com/pagefaultgames/rogueserver/defs"
@ -250,11 +250,11 @@ func RetrieveSystemSaveFromS3(uuid []byte) error {
err = StoreSystemSaveData(uuid, session)
if err != nil {
fmt.Printf("Failed to store system save data from s3 for user %s\n", username)
log.Printf("Failed to store system save data from s3 for user %s", username)
return err
}
fmt.Printf("Retrieved system save data from s3 for user %s\n", username)
log.Printf("Retrieved system save data from s3 for user %s", username)
_, err = handle.Exec("UPDATE accounts SET isInLocalDb = 1 WHERE uuid = ?", uuid)
if err != nil {
@ -266,7 +266,7 @@ func RetrieveSystemSaveFromS3(uuid []byte) error {
Key: aws.String(username),
})
if err != nil {
fmt.Printf("Failed to delete object %s from s3: %s\n", username, err)
log.Printf("Failed to delete object %s from s3: %s", username, err)
}
return nil
@ -297,7 +297,6 @@ func RetrieveOldAccounts() ([][]byte, error) {
func UpdateLocation(uuid []byte, username string) error {
_, err := handle.Exec("UPDATE accounts SET isInLocalDb = 0 WHERE uuid = ?", uuid)
if err != nil {
fmt.Printf("Failed to update location for user %s\n", username)
return err
}

Loading…
Cancel
Save