diff options
author | siddharth <s@ricketyspace.net> | 2021-11-28 20:14:34 -0500 |
---|---|---|
committer | siddharth <s@ricketyspace.net> | 2021-11-28 20:15:35 -0500 |
commit | 03cf36f11d7f09ccccbe52b2793b2c3f322d656a (patch) | |
tree | 232d9af00e0960ee63cc216c5ceec1d129e0f7da | |
parent | c1ace352e8ba09ec3c00317e72de6b871a8964ec (diff) |
feed: update feed
Add YDLPath to Feed. Set it during Validate().
-rw-r--r-- | config/config.go | 2 | ||||
-rw-r--r-- | feed/feed.go | 12 |
2 files changed, 11 insertions, 3 deletions
diff --git a/config/config.go b/config/config.go index 5f0e1fd..3d8c6f1 100644 --- a/config/config.go +++ b/config/config.go @@ -87,7 +87,7 @@ func (config *FernConfig) validate() error { return fmt.Errorf("'feeds' not set in config") } for _, feed := range config.Feeds { - err = feed.Validate(config.DumpDir) + err = feed.Validate(config.YDLPath, config.DumpDir) if err != nil { return err } diff --git a/feed/feed.go b/feed/feed.go index 631783b..3872af4 100644 --- a/feed/feed.go +++ b/feed/feed.go @@ -19,12 +19,17 @@ type Feed struct { Id string `json:"id"` Source string `json:"source"` Schema string `json:"schema"` + YDLPath string DumpDir string Object interface{} } -func (feed *Feed) Validate(baseDumpDir string) error { - _, err := os.Stat(baseDumpDir) +func (feed *Feed) Validate(ydlPath, baseDumpDir string) error { + _, err := os.Stat(ydlPath) + if err != nil { + return err + } + _, err = os.Stat(baseDumpDir) if err != nil { return err } @@ -51,6 +56,9 @@ func (feed *Feed) Validate(baseDumpDir string) error { feed.Schema, feed.Id) } + // Set ydl-path for feed. + feed.YDLPath = ydlPath + // Set dump directory for feed and ensure it exists. feed.DumpDir = path.Join(baseDumpDir, feed.Id) err = os.MkdirAll(feed.DumpDir, 0755) |