Skip to content

Commit c09da15

Browse files
committed
PR feedback
Signed-off-by: Grant Linville <[email protected]>
1 parent 28a4174 commit c09da15

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

pkg/repos/get.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,12 +114,13 @@ func (m *Manager) deferredSetUpCredentialHelpers(ctx context.Context, cliCfg *co
114114
defer locker.Unlock("gptscript-credential-helpers")
115115

116116
// Load the last-checked file to make sure we haven't checked the repo in the last 24 hours.
117+
now := time.Now()
117118
lastChecked, err := os.ReadFile(m.credHelperDirs.LastCheckedFile)
118119
if err == nil {
119-
if t, err := time.Parse(time.RFC3339, strings.TrimSpace(string(lastChecked))); err == nil && time.Since(t) < 24*time.Hour {
120+
if t, err := time.Parse(time.RFC3339, strings.TrimSpace(string(lastChecked))); err == nil && now.Sub(t) < 24*time.Hour {
120121
// Make sure the binary still exists, and if it does, return.
121122
if _, err := os.Stat(filepath.Join(m.credHelperDirs.BinDir, "gptscript-credential-"+helperName+suffix)); err == nil {
122-
log.Debugf("Credential helper %s up-to-date as of %v, checking for updates after %v", helperName, t, lastChecked.Add(24*time.Hour))
123+
log.Debugf("Credential helper %s up-to-date as of %v, checking for updates after %v", helperName, t, t.Add(24*time.Hour))
123124
return nil
124125
}
125126
}
@@ -132,7 +133,7 @@ func (m *Manager) deferredSetUpCredentialHelpers(ctx context.Context, cliCfg *co
132133
}
133134

134135
// Update the last-checked file.
135-
if err := os.WriteFile(m.credHelperDirs.LastCheckedFile, []byte(time.Now().Format(time.RFC3339)), 0644); err != nil {
136+
if err := os.WriteFile(m.credHelperDirs.LastCheckedFile, []byte(now.Format(time.RFC3339)), 0644); err != nil {
136137
return err
137138
}
138139

0 commit comments

Comments
 (0)