Skip to content

Commit

Permalink
Set modification and access times for every saved file
Browse files Browse the repository at this point in the history
Make sure that the file times are set even if the server did not report 'Last-Modified'
  • Loading branch information
anatol committed Nov 19, 2024
1 parent 2c24be4 commit cbafc19
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions downloader.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,10 +172,12 @@ func (d *Downloader) downloadFromUpstream(repoURL string, proxyURL *url.URL) err
return err
}

if !d.modificationTime.IsZero() {
if err := os.Chtimes(d.outputFileName, time.Now(), d.modificationTime); err != nil {
return err
}
modTime := d.modificationTime
if modTime.IsZero() {
modTime = time.Now()
}
if err := os.Chtimes(d.outputFileName, time.Now(), modTime); err != nil {
return err
}

cacheSizeGauge.WithLabelValues(d.repoName).Add(float64(d.contentLength))
Expand Down

0 comments on commit cbafc19

Please sign in to comment.