@@ -83,23 +83,21 @@ func NewFileCache(root string) (*FileCache, error) {
83
83
// or the content has expired, corecrl.ErrCacheMiss is returned.
84
84
func (c * FileCache ) Get (ctx context.Context , url string ) (* corecrl.Bundle , error ) {
85
85
logger := log .GetLogger (ctx )
86
- logger .Infof ("Retrieving crl bundle from file cache with key %q ..." , url )
86
+ logger .Debugf ("Retrieving crl bundle from file cache with key %q ..." , url )
87
87
88
88
// get content from file cache
89
- f , err := os .Open (filepath .Join (c .root , c .fileName (url )))
89
+ contentBytes , err := os .ReadFile (filepath .Join (c .root , c .fileName (url )))
90
90
if err != nil {
91
91
if errors .Is (err , fs .ErrNotExist ) {
92
- logger .Infof ("CRL file cache miss. Key %q does not exist" , url )
92
+ logger .Debugf ("CRL file cache miss. Key %q does not exist" , url )
93
93
return nil , corecrl .ErrCacheMiss
94
94
}
95
95
return nil , fmt .Errorf ("failed to get crl bundle from file cache with key %q: %w" , url , err )
96
96
}
97
- defer f .Close ()
98
97
99
98
// decode content to crl Bundle
100
99
var content fileCacheContent
101
- err = json .NewDecoder (f ).Decode (& content )
102
- if err != nil {
100
+ if err := json .Unmarshal (contentBytes , & content ); err != nil {
103
101
return nil , fmt .Errorf ("failed to decode file retrieved from file cache: %w" , err )
104
102
}
105
103
var bundle corecrl.Bundle
@@ -130,7 +128,7 @@ func (c *FileCache) Get(ctx context.Context, url string) (*corecrl.Bundle, error
130
128
// Set stores the CRL bundle in c with url as key.
131
129
func (c * FileCache ) Set (ctx context.Context , url string , bundle * corecrl.Bundle ) (setErr error ) {
132
130
logger := log .GetLogger (ctx )
133
- logger .Infof ("Storing crl bundle to file cache with key %q ..." , url )
131
+ logger .Debugf ("Storing crl bundle to file cache with key %q ..." , url )
134
132
135
133
// sanity check
136
134
if bundle == nil {
@@ -188,7 +186,7 @@ func checkExpiry(ctx context.Context, nextUpdate time.Time) error {
188
186
return errors .New ("crl bundle retrieved from file cache does not contain valid NextUpdate" )
189
187
}
190
188
if time .Now ().After (nextUpdate ) {
191
- logger .Infof ("CRL bundle retrieved from file cache has expired at %s" , nextUpdate )
189
+ logger .Debugf ("CRL bundle retrieved from file cache has expired at %s" , nextUpdate )
192
190
return corecrl .ErrCacheMiss
193
191
}
194
192
return nil
0 commit comments