Skip to content

Commit 55a1de2

Browse files
committed
fixup! address PR comments
1 parent 67516c7 commit 55a1de2

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

cli/ssh.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ func tryPollWorkspaceAutostop(ctx context.Context, client *codersdk.Client, work
201201
lockStat, err := os.Stat(lockPath)
202202
if err == nil {
203203
// 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())
205205
if lockAge < 3*autostopPollInterval {
206206
// Lock file exists and is still "fresh". Do nothing.
207207
return func() {}
@@ -224,6 +224,8 @@ func tryPollWorkspaceAutostop(ctx context.Context, client *codersdk.Client, work
224224
// Notify the user if the workspace is due to shutdown.
225225
func notifyCondition(ctx context.Context, client *codersdk.Client, workspaceID uuid.UUID, lockFile *os.File) notify.Condition {
226226
return func(now time.Time) (deadline time.Time, callback func()) {
227+
// update lockFile (best effort)
228+
_ = os.Chtimes(lockFile.Name(), now, now)
227229
ws, err := client.Workspace(ctx, workspaceID)
228230
if err != nil {
229231
return time.Time{}, nil
@@ -255,8 +257,6 @@ func notifyCondition(ctx context.Context, client *codersdk.Client, workspaceID u
255257
}
256258
// notify user with a native system notification (best effort)
257259
_ = beeep.Notify(title, body, "")
258-
// update lockFile (best effort)
259-
_ = os.Chtimes(lockFile.Name(), now, now)
260260
}
261261
return deadline.Truncate(time.Minute), callback
262262
}

0 commit comments

Comments
 (0)