mirror of
https://github.com/go-gitea/gitea
synced 2024-07-27 17:17:08 +02:00
Compare commits
5 Commits
c35b843412
...
d613e2396e
Author | SHA1 | Date | |
---|---|---|---|
|
d613e2396e | ||
|
a40192dc12 | ||
|
e1cf760d2f | ||
|
7ebf151258 | ||
|
ee997bb004 |
|
@ -136,14 +136,13 @@ func (c *HTTPClient) performOperation(ctx context.Context, objects []Pointer, dc
|
|||
|
||||
for _, object := range result.Objects {
|
||||
if object.Error != nil {
|
||||
objectError := errors.New(object.Error.Message)
|
||||
log.Trace("Error on object %v: %v", object.Pointer, objectError)
|
||||
log.Trace("Error on object %v: %v", object.Pointer, object.Error)
|
||||
if uc != nil {
|
||||
if _, err := uc(object.Pointer, objectError); err != nil {
|
||||
if _, err := uc(object.Pointer, object.Error); err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
if err := dc(object.Pointer, nil, objectError); err != nil {
|
||||
if err := dc(object.Pointer, nil, object.Error); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,7 +4,11 @@
|
|||
package lfs
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"code.gitea.io/gitea/modules/util"
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -64,6 +68,39 @@ type ObjectError struct {
|
|||
Message string `json:"message"`
|
||||
}
|
||||
|
||||
var (
|
||||
// See https://github.com/git-lfs/git-lfs/blob/main/docs/api/batch.md#successful-responses
|
||||
// LFS object error codes should match HTTP status codes where possible:
|
||||
// 404 - The object does not exist on the server.
|
||||
// 409 - The specified hash algorithm disagrees with the server's acceptable options.
|
||||
// 410 - The object was removed by the owner.
|
||||
// 422 - Validation error.
|
||||
|
||||
ErrObjectNotExist = util.ErrNotExist // the object does not exist on the server
|
||||
ErrObjectHashMismatch = errors.New("the specified hash algorithm disagrees with the server's acceptable options")
|
||||
ErrObjectRemoved = errors.New("the object was removed by the owner")
|
||||
ErrObjectValidation = errors.New("validation error")
|
||||
)
|
||||
|
||||
func (e *ObjectError) Error() string {
|
||||
return fmt.Sprintf("[%d] %s", e.Code, e.Message)
|
||||
}
|
||||
|
||||
func (e *ObjectError) Unwrap() error {
|
||||
switch e.Code {
|
||||
case 404:
|
||||
return ErrObjectNotExist
|
||||
case 409:
|
||||
return ErrObjectHashMismatch
|
||||
case 410:
|
||||
return ErrObjectRemoved
|
||||
case 422:
|
||||
return ErrObjectValidation
|
||||
default:
|
||||
return errors.New(e.Message)
|
||||
}
|
||||
}
|
||||
|
||||
// PointerBlob associates a Git blob with a Pointer.
|
||||
type PointerBlob struct {
|
||||
Hash string
|
||||
|
|
|
@ -5,6 +5,7 @@ package repository
|
|||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"strings"
|
||||
|
@ -181,6 +182,10 @@ func StoreMissingLfsObjectsInRepository(ctx context.Context, repo *repo_model.Re
|
|||
downloadObjects := func(pointers []lfs.Pointer) error {
|
||||
err := lfsClient.Download(ctx, pointers, func(p lfs.Pointer, content io.ReadCloser, objectError error) error {
|
||||
if objectError != nil {
|
||||
if errors.Is(objectError, lfs.ErrObjectNotExist) {
|
||||
log.Warn("Repo[%-v]: Ignore missing LFS object %-v: %v", repo, p, objectError)
|
||||
return nil
|
||||
}
|
||||
return objectError
|
||||
}
|
||||
|
||||
|
|
|
@ -2981,6 +2981,10 @@ emails.not_updated=Falhou a modificação do endereço de email solicitado: %v
|
|||
emails.duplicate_active=Este endereço de email já está a ser usado por outro utilizador.
|
||||
emails.change_email_header=Modificar propriedades do email
|
||||
emails.change_email_text=Tem a certeza que quer modificar este endereço de email?
|
||||
emails.delete=Eliminar email
|
||||
emails.delete_desc=Tem a certeza que quer eliminar este endereço de email?
|
||||
emails.deletion_success=O endereço de email foi eliminado.
|
||||
emails.delete_primary_email_error=Não pode eliminar o email principal.
|
||||
|
||||
orgs.org_manage_panel=Gestão das organizações
|
||||
orgs.name=Nome
|
||||
|
|
|
@ -327,7 +327,7 @@ func getOAuthGroupsForUser(ctx go_context.Context, user *user_model.User) ([]str
|
|||
|
||||
func parseBasicAuth(ctx *context.Context) (username, password string, err error) {
|
||||
authHeader := ctx.Req.Header.Get("Authorization")
|
||||
if authType, authData, ok := strings.Cut(authHeader, " "); ok && authType == "Basic" {
|
||||
if authType, authData, ok := strings.Cut(authHeader, " "); ok && strings.EqualFold(authType, "Basic") {
|
||||
return base.BasicAuthDecode(authData)
|
||||
}
|
||||
return "", "", errors.New("invalid basic authentication")
|
||||
|
@ -661,7 +661,7 @@ func AccessTokenOAuth(ctx *context.Context) {
|
|||
// if there is no ClientID or ClientSecret in the request body, fill these fields by the Authorization header and ensure the provided field matches the Authorization header
|
||||
if form.ClientID == "" || form.ClientSecret == "" {
|
||||
authHeader := ctx.Req.Header.Get("Authorization")
|
||||
if authType, authData, ok := strings.Cut(authHeader, " "); ok && authType == "Basic" {
|
||||
if authType, authData, ok := strings.Cut(authHeader, " "); ok && strings.EqualFold(authType, "Basic") {
|
||||
clientID, clientSecret, err := base.BasicAuthDecode(authData)
|
||||
if err != nil {
|
||||
handleAccessTokenError(ctx, AccessTokenError{
|
||||
|
|
|
@ -169,6 +169,7 @@ func MigrateRepositoryGitData(ctx context.Context, u *user_model.User,
|
|||
lfsClient := lfs.NewClient(endpoint, httpTransport)
|
||||
if err = repo_module.StoreMissingLfsObjectsInRepository(ctx, repo, gitRepo, lfsClient); err != nil {
|
||||
log.Error("Failed to store missing LFS objects for repository: %v", err)
|
||||
return repo, fmt.Errorf("StoreMissingLfsObjectsInRepository: %w", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user