@@ -21,7 +21,9 @@ import (
2121func UploadAvatar (ctx context.Context , repo * repo_model.Repository , data []byte ) error {
2222 avatarData , err := avatar .ProcessAvatarImage (data )
2323 if err != nil {
24- return err
24+ // if the image is not valid, just log the error and return nil, don't block other operations (e.g. repo creation)
25+ log .Debug ("UploadAvatar: failed to process repo avatar image: %v" , err )
26+ return nil
2527 }
2628
2729 newAvatar := avatar .HashAvatar (repo .ID , data )
@@ -36,19 +38,19 @@ func UploadAvatar(ctx context.Context, repo *repo_model.Repository, data []byte)
3638 // Then repo will be removed - only it avatar file will be removed
3739 repo .Avatar = newAvatar
3840 if err := repo_model .UpdateRepositoryColsNoAutoTime (ctx , repo , "avatar" ); err != nil {
39- return fmt .Errorf ("UploadAvatar: Update repository avatar: %w" , err )
41+ return fmt .Errorf ("UploadAvatar: failed to update repository avatar: %w" , err )
4042 }
4143
4244 if err := storage .SaveFrom (storage .RepoAvatars , repo .CustomAvatarRelativePath (), func (w io.Writer ) error {
4345 _ , err := w .Write (avatarData )
4446 return err
4547 }); err != nil {
46- return fmt .Errorf ("UploadAvatar %s failed: Failed to remove old repo avatar %s: %w" , repo . RelativePath () , newAvatar , err )
48+ return fmt .Errorf ("UploadAvatar: failed to save repo avatar %s: %w" , newAvatar , err )
4749 }
4850
4951 if len (oldAvatarPath ) > 0 {
5052 if err := storage .RepoAvatars .Delete (oldAvatarPath ); err != nil {
51- return fmt .Errorf ("UploadAvatar: Failed to remove old repo avatar %s: %w" , oldAvatarPath , err )
53+ return fmt .Errorf ("UploadAvatar: failed to remove old repo avatar %s: %w" , oldAvatarPath , err )
5254 }
5355 }
5456 return nil
0 commit comments