@@ -201,7 +201,7 @@ func tryPollWorkspaceAutostop(ctx context.Context, client *codersdk.Client, work
201
201
lockStat , err := os .Stat (lockPath )
202
202
if err == nil {
203
203
// Lock file already exists for this workspace. How old is it?
204
- lockAge := lockStat . ModTime ().Sub (time . Now ())
204
+ lockAge := time . Now ().Sub (lockStat . ModTime ())
205
205
if lockAge < 3 * autostopPollInterval {
206
206
// Lock file exists and is still "fresh". Do nothing.
207
207
return func () {}
@@ -224,6 +224,8 @@ func tryPollWorkspaceAutostop(ctx context.Context, client *codersdk.Client, work
224
224
// Notify the user if the workspace is due to shutdown.
225
225
func notifyCondition (ctx context.Context , client * codersdk.Client , workspaceID uuid.UUID , lockFile * os.File ) notify.Condition {
226
226
return func (now time.Time ) (deadline time.Time , callback func ()) {
227
+ // update lockFile (best effort)
228
+ _ = os .Chtimes (lockFile .Name (), now , now )
227
229
ws , err := client .Workspace (ctx , workspaceID )
228
230
if err != nil {
229
231
return time.Time {}, nil
@@ -255,8 +257,6 @@ func notifyCondition(ctx context.Context, client *codersdk.Client, workspaceID u
255
257
}
256
258
// notify user with a native system notification (best effort)
257
259
_ = beeep .Notify (title , body , "" )
258
- // update lockFile (best effort)
259
- _ = os .Chtimes (lockFile .Name (), now , now )
260
260
}
261
261
return deadline .Truncate (time .Minute ), callback
262
262
}
0 commit comments