diff options
author | Lunny Xiao <xiaolunwen@gmail.com> | 2017-12-02 15:34:39 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-12-02 15:34:39 +0800 |
commit | 35cc5b0402d46d672e02bbe1ad15d1460077e8f4 (patch) | |
tree | 47723925eb89e286f328503ae30e77ca1eaaf021 /modules/lfs | |
parent | 674422b642452050a7185f10908a9e8a86604f24 (diff) | |
download | gitea-35cc5b0402d46d672e02bbe1ad15d1460077e8f4.tar.gz gitea-35cc5b0402d46d672e02bbe1ad15d1460077e8f4.zip |
Remove GetRepositoryByRef and add GetRepositoryByOwnerAndName (#3043)
* remove GetRepositoryByRef and add GetRepositoryByOwnerAndName
* fix tests
* fix tests bug
* some improvements
Diffstat (limited to 'modules/lfs')
-rw-r--r-- | modules/lfs/server.go | 17 |
1 files changed, 6 insertions, 11 deletions
diff --git a/modules/lfs/server.go b/modules/lfs/server.go index 68f2af1519..474a3f56c3 100644 --- a/modules/lfs/server.go +++ b/modules/lfs/server.go @@ -108,10 +108,9 @@ func ObjectOidHandler(ctx *context.Context) { } func getAuthenticatedRepoAndMeta(ctx *context.Context, rv *RequestVars, requireWrite bool) (*models.LFSMetaObject, *models.Repository) { - repositoryString := rv.User + "/" + rv.Repo - repository, err := models.GetRepositoryByRef(repositoryString) + repository, err := models.GetRepositoryByOwnerAndName(rv.User, rv.Repo) if err != nil { - log.Debug("Could not find repository: %s - %s", repositoryString, err) + log.Debug("Could not find repository: %s/%s - %s", rv.User, rv.Repo, err) writeStatus(ctx, 404) return nil, nil } @@ -197,7 +196,6 @@ func getMetaHandler(ctx *context.Context) { // PostHandler instructs the client how to upload data func PostHandler(ctx *context.Context) { - if !setting.LFS.StartServer { writeStatus(ctx, 404) return @@ -210,10 +208,9 @@ func PostHandler(ctx *context.Context) { rv := unpack(ctx) - repositoryString := rv.User + "/" + rv.Repo - repository, err := models.GetRepositoryByRef(repositoryString) + repository, err := models.GetRepositoryByOwnerAndName(rv.User, rv.Repo) if err != nil { - log.Debug("Could not find repository: %s - %s", repositoryString, err) + log.Debug("Could not find repository: %s/%s - %s", rv.User, rv.Repo, err) writeStatus(ctx, 404) return } @@ -261,12 +258,10 @@ func BatchHandler(ctx *context.Context) { // Create a response object for _, object := range bv.Objects { - - repositoryString := object.User + "/" + object.Repo - repository, err := models.GetRepositoryByRef(repositoryString) + repository, err := models.GetRepositoryByOwnerAndName(object.User, object.Repo) if err != nil { - log.Debug("Could not find repository: %s - %s", repositoryString, err) + log.Debug("Could not find repository: %s/%s - %s", object.User, object.Repo, err) writeStatus(ctx, 404) return } |