From 5fa2cbc1cd4c2ccbdf8897fcf9b5263ab050fbf6 Mon Sep 17 00:00:00 2001 From: Paul Duncan Date: Thu, 24 Feb 2022 00:52:19 -0500 Subject: nvdmirror: break Sync() into logical chunks, move into syncContext --- nvdmirror/util.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'nvdmirror/util.go') diff --git a/nvdmirror/util.go b/nvdmirror/util.go index 9cf7d3a..d54e41b 100644 --- a/nvdmirror/util.go +++ b/nvdmirror/util.go @@ -16,7 +16,7 @@ func getFileSize(path string) (uint64, error) { } } -// log array of strings +// Log array of strings. func logArray(key string, strs []string) { // populate array a := zerolog.Arr() @@ -27,3 +27,12 @@ func logArray(key string, strs []string) { // 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"), + }) +} -- cgit v1.2.3