fix: RequestRelease needs to be inside for, but after we check for a non-busy error
This commit is contained in:
parent
60e917120d
commit
5465cf7a63
|
@ -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 {
|
||||
|
|
Loading…
Reference in New Issue