diff options
author | zeripath <art27@cantab.net> | 2021-09-23 17:45:36 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-09-23 17:45:36 +0200 |
commit | 9302eba971611601c3ebf6024e22a11c63f4e151 (patch) | |
tree | a3e5583986161ef62e7affc694098279ecf2217d /services/attachment | |
parent | Fix typo skipping a migration (#17130) (diff) | |
download | forgejo-9302eba971611601c3ebf6024e22a11c63f4e151.tar.xz forgejo-9302eba971611601c3ebf6024e22a11c63f4e151.zip |
DBContext is just a Context (#17100)
* DBContext is just a Context
This PR removes some of the specialness from the DBContext and makes it context
This allows us to simplify the GetEngine code to wrap around any context in future
and means that we can change our loadRepo(e Engine) functions to simply take contexts.
Signed-off-by: Andrew Thornton <art27@cantab.net>
* fix unit tests
Signed-off-by: Andrew Thornton <art27@cantab.net>
* another place that needs to set the initial context
Signed-off-by: Andrew Thornton <art27@cantab.net>
* avoid race
Signed-off-by: Andrew Thornton <art27@cantab.net>
* change attachment error
Signed-off-by: Andrew Thornton <art27@cantab.net>
Diffstat (limited to 'services/attachment')
-rw-r--r-- | services/attachment/attachment.go | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/services/attachment/attachment.go b/services/attachment/attachment.go index 06f79be01b..7500a8ac3a 100644 --- a/services/attachment/attachment.go +++ b/services/attachment/attachment.go @@ -6,6 +6,7 @@ package attachment import ( "bytes" + "context" "fmt" "io" @@ -23,7 +24,7 @@ func NewAttachment(attach *models.Attachment, file io.Reader) (*models.Attachmen return nil, fmt.Errorf("attachment %s should belong to a repository", attach.Name) } - err := db.WithTx(func(ctx *db.Context) error { + err := db.WithTx(func(ctx context.Context) error { attach.UUID = uuid.New().String() size, err := storage.Attachments.Save(attach.RelativePath(), file, -1) if err != nil { |