diff options
author | Lunny Xiao <xiaolunwen@gmail.com> | 2021-01-07 03:23:57 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-01-06 19:23:57 +0000 |
commit | 3c96a3716288b0ae1ae65df44cc92218b489b77f (patch) | |
tree | 014f698c969dfaad3602681e07140f75263889a9 /routers/repo | |
parent | 8688c2be95f1d11fadd6cbb979eafe0bb817589a (diff) | |
download | gitea-3c96a3716288b0ae1ae65df44cc92218b489b77f.tar.gz gitea-3c96a3716288b0ae1ae65df44cc92218b489b77f.zip |
Some code improvements (#14266)
Diffstat (limited to 'routers/repo')
-rw-r--r-- | routers/repo/lfs.go | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/routers/repo/lfs.go b/routers/repo/lfs.go index dc3ab4f54c..01bbd192bc 100644 --- a/routers/repo/lfs.go +++ b/routers/repo/lfs.go @@ -120,13 +120,16 @@ func LFSLocks(ctx *context.Context) { }); err != nil { log.Error("Failed to clone repository: %s (%v)", ctx.Repo.Repository.FullName(), err) ctx.ServerError("LFSLocks", fmt.Errorf("Failed to clone repository: %s (%v)", ctx.Repo.Repository.FullName(), err)) + return } gitRepo, err := git.OpenRepository(tmpBasePath) if err != nil { log.Error("Unable to open temporary repository: %s (%v)", tmpBasePath, err) ctx.ServerError("LFSLocks", fmt.Errorf("Failed to open new temporary repository in: %s %v", tmpBasePath, err)) + return } + defer gitRepo.Close() filenames := make([]string, len(lfsLocks)) @@ -137,6 +140,7 @@ func LFSLocks(ctx *context.Context) { if err := gitRepo.ReadTreeToIndex(ctx.Repo.Repository.DefaultBranch); err != nil { log.Error("Unable to read the default branch to the index: %s (%v)", ctx.Repo.Repository.DefaultBranch, err) ctx.ServerError("LFSLocks", fmt.Errorf("Unable to read the default branch to the index: %s (%v)", ctx.Repo.Repository.DefaultBranch, err)) + return } name2attribute2info, err := gitRepo.CheckAttribute(git.CheckAttributeOpts{ @@ -147,6 +151,7 @@ func LFSLocks(ctx *context.Context) { if err != nil { log.Error("Unable to check attributes in %s (%v)", tmpBasePath, err) ctx.ServerError("LFSLocks", err) + return } lockables := make([]bool, len(lfsLocks)) @@ -166,6 +171,7 @@ func LFSLocks(ctx *context.Context) { if err != nil { log.Error("Unable to lsfiles in %s (%v)", tmpBasePath, err) ctx.ServerError("LFSLocks", err) + return } filemap := make(map[string]bool, len(filelist)) |