fix: RequestRelease needs to be inside for, but after we check for a non-busy error

This commit is contained in:
Derrick Hammer 2024-01-20 10:48:42 -05:00
parent 60e917120d
commit 5465cf7a63
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
1 changed files with 5 additions and 5 deletions

View File

@ -52,6 +52,11 @@ func (l *Lock) Lock(ctx context.Context, requestUnlock func()) error {
return err
}
err = l.lockRecord.RequestRelease(db)
if err != nil {
return err
}
select {
case <-ctx.Done():
// Context expired, so we return a timeout
@ -62,11 +67,6 @@ func (l *Lock) Lock(ctx context.Context, requestUnlock func()) error {
}
}
err := l.lockRecord.RequestRelease(db)
if err != nil {
return err
}
defer func(lockRecord *models.TusLock, db *gorm.DB) {
err := lockRecord.Released(db)
if err != nil {