diff options
Diffstat (limited to 'services/lfs/server.go')
-rw-r--r-- | services/lfs/server.go | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/services/lfs/server.go b/services/lfs/server.go index 2b0c8265c0..df0a8bd39a 100644 --- a/services/lfs/server.go +++ b/services/lfs/server.go @@ -20,6 +20,7 @@ import ( "code.gitea.io/gitea/models" "code.gitea.io/gitea/models/perm" + repo_model "code.gitea.io/gitea/models/repo" "code.gitea.io/gitea/models/unit" user_model "code.gitea.io/gitea/models/user" "code.gitea.io/gitea/modules/context" @@ -195,7 +196,7 @@ func BatchHandler(ctx *context.Context) { return } - meta, err := repository.GetLFSMetaObjectByOid(p.Oid) + meta, err := models.GetLFSMetaObjectByOid(repository.ID, p.Oid) if err != nil && err != models.ErrLFSObjectNotExist { log.Error("Unable to get LFS MetaObject [%s] for %s/%s. Error: %v", p.Oid, rc.User, rc.Repo, err) writeStatus(ctx, http.StatusInternalServerError) @@ -333,7 +334,7 @@ func UploadHandler(ctx *context.Context) { } else { writeStatus(ctx, http.StatusInternalServerError) } - if _, err = repository.RemoveLFSMetaObjectByOid(p.Oid); err != nil { + if _, err = models.RemoveLFSMetaObjectByOid(repository.ID, p.Oid); err != nil { log.Error("Error whilst removing metaobject for LFS OID[%s]: %v", p.Oid, err) } return @@ -396,7 +397,7 @@ func getAuthenticatedMeta(ctx *context.Context, rc *requestContext, p lfs_module return nil } - meta, err := repository.GetLFSMetaObjectByOid(p.Oid) + meta, err := models.GetLFSMetaObjectByOid(repository.ID, p.Oid) if err != nil { log.Error("Unable to get LFS OID[%s] Error: %v", p.Oid, err) writeStatus(ctx, http.StatusNotFound) @@ -406,8 +407,8 @@ func getAuthenticatedMeta(ctx *context.Context, rc *requestContext, p lfs_module return meta } -func getAuthenticatedRepository(ctx *context.Context, rc *requestContext, requireWrite bool) *models.Repository { - repository, err := models.GetRepositoryByOwnerAndName(rc.User, rc.Repo) +func getAuthenticatedRepository(ctx *context.Context, rc *requestContext, requireWrite bool) *repo_model.Repository { + repository, err := repo_model.GetRepositoryByOwnerAndName(rc.User, rc.Repo) if err != nil { log.Error("Unable to get repository: %s/%s Error: %v", rc.User, rc.Repo, err) writeStatus(ctx, http.StatusNotFound) @@ -480,7 +481,7 @@ func writeStatusMessage(ctx *context.Context, status int, message string) { // authenticate uses the authorization string to determine whether // or not to proceed. This server assumes an HTTP Basic auth format. -func authenticate(ctx *context.Context, repository *models.Repository, authorization string, requireSigned, requireWrite bool) bool { +func authenticate(ctx *context.Context, repository *repo_model.Repository, authorization string, requireSigned, requireWrite bool) bool { accessMode := perm.AccessModeRead if requireWrite { accessMode = perm.AccessModeWrite @@ -508,7 +509,7 @@ func authenticate(ctx *context.Context, repository *models.Repository, authoriza return true } -func handleLFSToken(tokenSHA string, target *models.Repository, mode perm.AccessMode) (*user_model.User, error) { +func handleLFSToken(tokenSHA string, target *repo_model.Repository, mode perm.AccessMode) (*user_model.User, error) { if !strings.Contains(tokenSHA, ".") { return nil, nil } @@ -543,7 +544,7 @@ func handleLFSToken(tokenSHA string, target *models.Repository, mode perm.Access return u, nil } -func parseToken(authorization string, target *models.Repository, mode perm.AccessMode) (*user_model.User, error) { +func parseToken(authorization string, target *repo_model.Repository, mode perm.AccessMode) (*user_model.User, error) { if authorization == "" { return nil, fmt.Errorf("no token") } |