refactor: simplify serverlock code (#37451)

This commit is contained in:
cyhone 2021-08-17 21:34:03 +08:00 committed by GitHub
parent 0d2aaed3e8
commit 6aa2a0dc8a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -39,7 +39,7 @@ func (sl *ServerLockService) LockAndExecute(ctx context.Context, actionName stri
// avoid execution if last lock happened less than `maxInterval` ago
if rowLock.LastExecution != 0 {
lastExecutionTime := time.Unix(rowLock.LastExecution, 0)
if lastExecutionTime.Unix() > time.Now().Add(-maxInterval).Unix() {
if time.Since(lastExecutionTime) < maxInterval {
return nil
}
}