diff options
author | zeripath <art27@cantab.net> | 2019-11-13 07:01:19 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-11-13 07:01:19 +0000 |
commit | 722a7c902dd39bd3d4328345ca969220640774d7 (patch) | |
tree | 7fb83b70fd9df55fd7d3a805adf38238d6a9bca8 /modules/migrations | |
parent | 7b97e045557788efee6803261cf612eaf975c6be (diff) | |
download | gitea-722a7c902dd39bd3d4328345ca969220640774d7.tar.gz gitea-722a7c902dd39bd3d4328345ca969220640774d7.zip |
Add Close() method to gogitRepository (#8901)
In investigating #7947 it has become clear that the storage component of go-git repositories needs closing.
This PR adds this Close function and adds the Close functions as necessary.
In TransferOwnership the ctx.Repo.GitRepo is closed if it is open to help prevent the risk of multiple open files.
Fixes #7947
Diffstat (limited to 'modules/migrations')
-rw-r--r-- | modules/migrations/base/uploader.go | 1 | ||||
-rw-r--r-- | modules/migrations/gitea.go | 7 | ||||
-rw-r--r-- | modules/migrations/migrate.go | 1 |
3 files changed, 9 insertions, 0 deletions
diff --git a/modules/migrations/base/uploader.go b/modules/migrations/base/uploader.go index a3a9c9fac6..ae1be84b88 100644 --- a/modules/migrations/base/uploader.go +++ b/modules/migrations/base/uploader.go @@ -17,4 +17,5 @@ type Uploader interface { CreateComments(comments ...*Comment) error CreatePullRequests(prs ...*PullRequest) error Rollback() error + Close() } diff --git a/modules/migrations/gitea.go b/modules/migrations/gitea.go index 676667b426..81a6116a23 100644 --- a/modules/migrations/gitea.go +++ b/modules/migrations/gitea.go @@ -131,6 +131,13 @@ func (g *GiteaLocalUploader) CreateRepo(repo *base.Repository, opts base.Migrate return err } +// Close closes this uploader +func (g *GiteaLocalUploader) Close() { + if g.gitRepo != nil { + g.gitRepo.Close() + } +} + // CreateTopics creates topics func (g *GiteaLocalUploader) CreateTopics(topics ...string) error { return models.SaveTopics(g.repo.ID, topics...) diff --git a/modules/migrations/migrate.go b/modules/migrations/migrate.go index bbc1dc2d56..7a5071e125 100644 --- a/modules/migrations/migrate.go +++ b/modules/migrations/migrate.go @@ -94,6 +94,7 @@ func migrateRepository(downloader base.Downloader, uploader base.Uploader, opts if err := uploader.CreateRepo(repo, opts); err != nil { return err } + defer uploader.Close() log.Trace("migrating topics") topics, err := downloader.GetTopics() |