1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
package nvdmirror
import (
"github.com/rs/zerolog"
"github.com/rs/zerolog/log"
"os"
)
// Get file size, in bytes.
func getFileSize(path string) (uint64, error) {
// verify that full path exists
if st, err := os.Stat(path); err != nil {
return 0, err
} else {
return uint64(st.Size()), err
}
}
// Log array of strings.
func logArray(key string, strs []string) {
// populate array
a := zerolog.Arr()
for _, v := range(strs) {
a.Str(v)
}
// log array
log.Info().Array(key, a).Send()
}
// Get source URL, etag response header, and last-modified response
// header from fetchResult and save them in the given cache.
func saveHeaders(cache Cache, fr fetchResult) error {
return cache.Set(fr.src, map[string]string {
"if-none-match": fr.headers.Get("etag"),
"if-modified-since": fr.headers.Get("last-modified"),
})
}
|