diff options
-rw-r--r-- | nvdmirror/nvdmirror.go | 23 | ||||
-rw-r--r-- | nvdmirror/util.go | 29 |
2 files changed, 29 insertions, 23 deletions
diff --git a/nvdmirror/nvdmirror.go b/nvdmirror/nvdmirror.go index aeb5c24..546a0ed 100644 --- a/nvdmirror/nvdmirror.go +++ b/nvdmirror/nvdmirror.go @@ -8,7 +8,6 @@ import ( "fmt" "github.com/pablotron/cvez/atomictemp" "github.com/pablotron/cvez/feed" - "github.com/rs/zerolog" "github.com/rs/zerolog/log" "io" "io/fs" @@ -195,16 +194,6 @@ func (me syncContext) getFileHash(path string) ([32]byte, error) { return r, nil } -// 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 - } -} - // Check the size and hash in the metadata file against the full file. // // Note: This method is called from a goroutine and returns it's value @@ -260,18 +249,6 @@ func (me syncContext) check(metaUrl, fullUrl string) { me.ch <- r } -// 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() -} - // Sync to destination directory and return an array of updated files. func Sync(config SyncConfig, cache Cache, dstDir string) []string { // log.Debug().Str("dstDir", dstDir).Msg("Sync") diff --git a/nvdmirror/util.go b/nvdmirror/util.go new file mode 100644 index 0000000..9cf7d3a --- /dev/null +++ b/nvdmirror/util.go @@ -0,0 +1,29 @@ +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() +} |