Try to simplify updateCache() to understand what it does
This commit is contained in:
parent
f567f57150
commit
ea3625bcfd
|
@ -7,7 +7,6 @@ import (
|
||||||
"math/rand"
|
"math/rand"
|
||||||
"net/url"
|
"net/url"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
@ -102,22 +101,14 @@ func writeSource(f string, bin, sig []byte) (err error) {
|
||||||
func (source *Source) updateCache(bin, sig []byte, now time.Time) {
|
func (source *Source) updateCache(bin, sig []byte, now time.Time) {
|
||||||
f := source.cacheFile
|
f := source.cacheFile
|
||||||
var writeErr error // an error writing cache isn't fatal
|
var writeErr error // an error writing cache isn't fatal
|
||||||
defer func() {
|
|
||||||
source.bin = bin
|
|
||||||
if writeErr == nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if absPath, absErr := filepath.Abs(f); absErr == nil {
|
|
||||||
f = absPath
|
|
||||||
}
|
|
||||||
dlog.Warnf("%s: %s", f, writeErr)
|
|
||||||
}()
|
|
||||||
if !bytes.Equal(source.bin, bin) {
|
if !bytes.Equal(source.bin, bin) {
|
||||||
if writeErr = writeSource(f, bin, sig); writeErr != nil {
|
if writeErr = writeSource(f, bin, sig); writeErr != nil {
|
||||||
|
source.bin = bin
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
writeErr = os.Chtimes(f, now, now)
|
os.Chtimes(f, now, now)
|
||||||
|
source.bin = bin
|
||||||
}
|
}
|
||||||
|
|
||||||
func (source *Source) parseURLs(urls []string) {
|
func (source *Source) parseURLs(urls []string) {
|
||||||
|
|
Loading…
Reference in New Issue