summaryrefslogtreecommitdiffstats
path: root/services
diff options
context:
space:
mode:
Diffstat (limited to 'services')
-rw-r--r--services/repository/avatar.go7
-rw-r--r--services/user/user.go7
2 files changed, 4 insertions, 10 deletions
diff --git a/services/repository/avatar.go b/services/repository/avatar.go
index 74e5de877e..38c2621bc4 100644
--- a/services/repository/avatar.go
+++ b/services/repository/avatar.go
@@ -6,7 +6,6 @@ package repository
import (
"context"
"fmt"
- "image/png"
"io"
"strconv"
"strings"
@@ -21,7 +20,7 @@ import (
// UploadAvatar saves custom avatar for repository.
// FIXME: split uploads to different subdirs in case we have massive number of repos.
func UploadAvatar(ctx context.Context, repo *repo_model.Repository, data []byte) error {
- m, err := avatar.Prepare(data)
+ avatarData, err := avatar.ProcessAvatarImage(data)
if err != nil {
return err
}
@@ -47,9 +46,7 @@ func UploadAvatar(ctx context.Context, repo *repo_model.Repository, data []byte)
}
if err := storage.SaveFrom(storage.RepoAvatars, repo.CustomAvatarRelativePath(), func(w io.Writer) error {
- if err := png.Encode(w, *m); err != nil {
- log.Error("Encode: %v", err)
- }
+ _, err := w.Write(avatarData)
return err
}); err != nil {
return fmt.Errorf("UploadAvatar %s failed: Failed to remove old repo avatar %s: %w", repo.RepoPath(), newAvatar, err)
diff --git a/services/user/user.go b/services/user/user.go
index d52a2f404b..5148f2168d 100644
--- a/services/user/user.go
+++ b/services/user/user.go
@@ -6,7 +6,6 @@ package user
import (
"context"
"fmt"
- "image/png"
"io"
"time"
@@ -244,7 +243,7 @@ func DeleteInactiveUsers(ctx context.Context, olderThan time.Duration) error {
// UploadAvatar saves custom avatar for user.
func UploadAvatar(u *user_model.User, data []byte) error {
- m, err := avatar.Prepare(data)
+ avatarData, err := avatar.ProcessAvatarImage(data)
if err != nil {
return err
}
@@ -262,9 +261,7 @@ func UploadAvatar(u *user_model.User, data []byte) error {
}
if err := storage.SaveFrom(storage.Avatars, u.CustomAvatarRelativePath(), func(w io.Writer) error {
- if err := png.Encode(w, *m); err != nil {
- log.Error("Encode: %v", err)
- }
+ _, err := w.Write(avatarData)
return err
}); err != nil {
return fmt.Errorf("Failed to create dir %s: %w", u.CustomAvatarRelativePath(), err)