fix: ErrObjectNotExist

This commit is contained in:
Jason Song 2024-07-26 10:21:38 +08:00
parent ee997bb004
commit 7ebf151258
No known key found for this signature in database
GPG Key ID: 8402EEEE4511A8B5
2 changed files with 5 additions and 3 deletions

View File

@ -7,6 +7,8 @@ import (
"errors" "errors"
"fmt" "fmt"
"time" "time"
"code.gitea.io/gitea/modules/util"
) )
const ( const (
@ -74,7 +76,7 @@ var (
// 410 - The object was removed by the owner. // 410 - The object was removed by the owner.
// 422 - Validation error. // 422 - Validation error.
ErrObjectNotFound = errors.New("the object does not exist on the server") 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") ErrObjectHashMismatch = errors.New("the specified hash algorithm disagrees with the server's acceptable options")
ErrObjectRemoved = errors.New("the object was removed by the owner") ErrObjectRemoved = errors.New("the object was removed by the owner")
ErrObjectValidation = errors.New("validation error") ErrObjectValidation = errors.New("validation error")
@ -87,7 +89,7 @@ func (e *ObjectError) Error() string {
func (e *ObjectError) Unwrap() error { func (e *ObjectError) Unwrap() error {
switch e.Code { switch e.Code {
case 404: case 404:
return ErrObjectNotFound return ErrObjectNotExist
case 409: case 409:
return ErrObjectHashMismatch return ErrObjectHashMismatch
case 410: case 410:

View File

@ -182,7 +182,7 @@ func StoreMissingLfsObjectsInRepository(ctx context.Context, repo *repo_model.Re
downloadObjects := func(pointers []lfs.Pointer) error { downloadObjects := func(pointers []lfs.Pointer) error {
err := lfsClient.Download(ctx, pointers, func(p lfs.Pointer, content io.ReadCloser, objectError error) error { err := lfsClient.Download(ctx, pointers, func(p lfs.Pointer, content io.ReadCloser, objectError error) error {
if objectError != nil { if objectError != nil {
if errors.Is(objectError, lfs.ErrObjectNotFound) { if errors.Is(objectError, lfs.ErrObjectNotExist) {
log.Warn("Repo[%-v]: Ignore missing LFS object %-v: %v", repo, p, objectError) log.Warn("Repo[%-v]: Ignore missing LFS object %-v: %v", repo, p, objectError)
return nil return nil
} }