mirror of
https://github.com/gocsaf/csaf.git
synced 2025-12-22 11:55:40 +01:00
Add option to specify download folder
* Add an option to downloader to store advisories into a given subfolder. --------- Co-authored-by: JanHoefelmeyer <hoefelmeyer.jan@gmail.com> Co-authored-by: Bernhard Reiter <bernhard@intevation.de>
This commit is contained in:
parent
d42db07bec
commit
8c95795b96
3 changed files with 16 additions and 2 deletions
|
|
@ -29,6 +29,7 @@ type config struct {
|
|||
Rate *float64 `long:"rate" short:"r" description:"The average upper limit of https operations per second (defaults to unlimited)" toml:"rate"`
|
||||
Worker int `long:"worker" short:"w" description:"NUMber of concurrent downloads" value-name:"NUM" toml:"worker"`
|
||||
Range *models.TimeRange `long:"timerange" short:"t" description:"RANGE of time from which advisories to download" value-name:"RANGE" toml:"timerange"`
|
||||
Folder string `long:"folder" short:"f" description:"Download into a given subFOLDER" value-name:"FOLDER" toml:"folder"`
|
||||
|
||||
ExtraHeader http.Header `long:"header" short:"H" description:"One or more extra HTTP header fields" toml:"header"`
|
||||
|
||||
|
|
|
|||
|
|
@ -474,8 +474,15 @@ nextAdvisory:
|
|||
initialReleaseDate = initialReleaseDate.UTC()
|
||||
|
||||
// Write advisory to file
|
||||
newDir := path.Join(d.directory, lower)
|
||||
|
||||
// Do we have a configured destination folder?
|
||||
if d.cfg.Folder != "" {
|
||||
newDir = path.Join(newDir, d.cfg.Folder)
|
||||
} else {
|
||||
newDir = path.Join(newDir, strconv.Itoa(initialReleaseDate.Year()))
|
||||
}
|
||||
|
||||
newDir := path.Join(d.directory, lower, strconv.Itoa(initialReleaseDate.Year()))
|
||||
if newDir != lastDir {
|
||||
if err := d.mkdirAll(newDir, 0755); err != nil {
|
||||
errorCh <- err
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ Application Options:
|
|||
-r, --rate= The average upper limit of https operations per second (defaults to unlimited)
|
||||
-w, --worker=NUM NUMber of concurrent downloads (default: 2)
|
||||
-t, --timerange=RANGE RANGE of time from which advisories to download
|
||||
-f, --folder=FOLDER Download all into a given subFOLDER
|
||||
-H, --header= One or more extra HTTP header fields
|
||||
--validator=URL URL to validate documents remotely
|
||||
--validatorcache=FILE FILE to cache remote validations
|
||||
|
|
@ -51,11 +52,12 @@ ignoresigcheck = false
|
|||
verbose = false
|
||||
# rate # set to unlimited
|
||||
worker = 2
|
||||
# timerange # not set by default
|
||||
# folder # not set by default
|
||||
# header # not set by default
|
||||
# validator # not set by default
|
||||
# validatorcache # not set by default
|
||||
validatorpreset = ["mandatory"]
|
||||
# timerange # not set by default
|
||||
```
|
||||
|
||||
The `timerange` parameter enables downloading advisories which last changes falls
|
||||
|
|
@ -86,3 +88,7 @@ into a given intervall. There are three possible notations:
|
|||
spans an interval from 1st January 2019 to the 1st January of 2024.
|
||||
|
||||
All interval boundaries are inclusive.
|
||||
|
||||
If the `folder` option is given all the advisories are stored in a subfolder
|
||||
of this name. Otherwise the advisories are each stored in a folder named
|
||||
by the year they are from.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue