fix(autocert): wrong path for last failure file

This commit is contained in:
yusing 2025-07-21 09:39:17 +08:00
parent a2e6688056
commit 68ac4f952d
2 changed files with 4 additions and 4 deletions

View file

@ -5,4 +5,5 @@ const (
CertFileDefault = certBasePath + "cert.crt" CertFileDefault = certBasePath + "cert.crt"
KeyFileDefault = certBasePath + "priv.key" KeyFileDefault = certBasePath + "priv.key"
ACMEKeyFileDefault = certBasePath + "acme.key" ACMEKeyFileDefault = certBasePath + "acme.key"
LastFailureFile = certBasePath + ".last_failure"
) )

View file

@ -8,7 +8,6 @@ import (
"maps" "maps"
"os" "os"
"path" "path"
"path/filepath"
"slices" "slices"
"strings" "strings"
"time" "time"
@ -83,7 +82,7 @@ func (p *Provider) GetExpiries() CertExpiries {
func (p *Provider) GetLastFailure() (time.Time, error) { func (p *Provider) GetLastFailure() (time.Time, error) {
if p.lastFailure.IsZero() { if p.lastFailure.IsZero() {
data, err := os.ReadFile(filepath.Join(p.cfg.CertPath, ".last_failure")) data, err := os.ReadFile(LastFailureFile)
if err != nil { if err != nil {
if !os.IsNotExist(err) { if !os.IsNotExist(err) {
return time.Time{}, err return time.Time{}, err
@ -98,12 +97,12 @@ func (p *Provider) GetLastFailure() (time.Time, error) {
func (p *Provider) UpdateLastFailure() error { func (p *Provider) UpdateLastFailure() error {
t := time.Now() t := time.Now()
p.lastFailure = t p.lastFailure = t
return os.WriteFile(filepath.Join(p.cfg.CertPath, ".last_failure"), t.AppendFormat(nil, time.RFC3339), 0o600) return os.WriteFile(LastFailureFile, t.AppendFormat(nil, time.RFC3339), 0o600)
} }
func (p *Provider) ClearLastFailure() error { func (p *Provider) ClearLastFailure() error {
p.lastFailure = time.Time{} p.lastFailure = time.Time{}
return os.Remove(filepath.Join(p.cfg.CertPath, ".last_failure")) return os.Remove(LastFailureFile)
} }
func (p *Provider) ObtainCert() error { func (p *Provider) ObtainCert() error {