1
0
Fork 0
mirror of https://github.com/gocsaf/csaf.git synced 2025-12-22 11:55:40 +01:00

Merge remote-tracking branch 'origin/unify-spelling-interims-csv' into rework-interim

This commit is contained in:
Sascha L. Teichmann 2022-08-02 17:06:39 +02:00
commit 2f65019e45
2 changed files with 22 additions and 9 deletions

View file

@ -24,6 +24,21 @@ import (
"github.com/csaf-poc/csaf_distribution/util"
)
const (
// interimsCSV is the name of the file to store the URLs
// of the interim advisories.
interimsCSV = "interims.csv"
// changesCSV is the name of the file to store the
// the paths to the advisories sorted in descending order
// of the release date along with the release date.
changesCSV = "changes.csv"
// indexTXT is the name of the file to store the
// the paths of the advisories.
indexTXT = "index.txt"
)
func (w *worker) writeInterims(label string, summaries []summary) error {
// Filter out the interims.
@ -44,7 +59,7 @@ func (w *worker) writeInterims(label string, summaries []summary) error {
ss[j].summary.CurrentReleaseDate)
})
fname := filepath.Join(w.dir, label, "interim.csv")
fname := filepath.Join(w.dir, label, interimsCSV)
f, err := os.Create(fname)
if err != nil {
return err
@ -85,7 +100,7 @@ func (w *worker) writeCSV(label string, summaries []summary) error {
ss[j].summary.CurrentReleaseDate)
})
fname := filepath.Join(w.dir, label, "changes.csv")
fname := filepath.Join(w.dir, label, changesCSV)
f, err := os.Create(fname)
if err != nil {
return err
@ -121,7 +136,7 @@ func (w *worker) writeCSV(label string, summaries []summary) error {
func (w *worker) writeIndex(label string, summaries []summary) error {
fname := filepath.Join(w.dir, label, "index.txt")
fname := filepath.Join(w.dir, label, indexTXT)
f, err := os.Create(fname)
if err != nil {
return err

View file

@ -195,8 +195,8 @@ func (w *worker) interimWork(wg *sync.WaitGroup, jobs <-chan *interimJob) {
label = strings.ToLower(label)
labelPath := filepath.Join(providerPath, label)
interimsCSV := filepath.Join(labelPath, "interims.csv")
interims, olds, err := readInterims(interimsCSV, tooOld)
interCSV := filepath.Join(labelPath, interimsCSV)
interims, olds, err := readInterims(interCSV, tooOld)
if err != nil {
return err
}
@ -222,8 +222,8 @@ func (w *worker) interimWork(wg *sync.WaitGroup, jobs <-chan *interimJob) {
if err != nil {
return err
}
interimsCSV := filepath.Join(dst, label, "interims.csv")
if err := writeInterims(interimsCSV, notFinalized); err != nil {
interCSV := filepath.Join(dst, label, interimsCSV)
if err := writeInterims(interCSV, notFinalized); err != nil {
return err
}
}
@ -289,7 +289,6 @@ func (p *processor) interim() error {
type interimsEntry [3]string
func (ie interimsEntry) date() string { return ie[0] }
func (ie interimsEntry) url() string { return ie[1] }
func (ie interimsEntry) path() string { return ie[2] }
@ -298,7 +297,6 @@ func writeInterims(interimsCSV string, interims []interimsEntry) error {
if len(interims) == 0 {
return os.RemoveAll(interimsCSV)
}
return os.RemoveAll(interimsCSV)
// Overwrite old. It's save because we are in a transaction.
f, err := os.Create(interimsCSV)