Skip to content

Commit

Permalink
Merge pull request #72 from jmillerv/9-14-2023-fix
Browse files Browse the repository at this point in the history
9-14-2023 Fix
  • Loading branch information
jmillerv authored Sep 19, 2023
2 parents 809a66f + e2b70ff commit 285af88
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 10 deletions.
12 changes: 8 additions & 4 deletions content/podcast.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,11 +119,15 @@ func (p *Podcast) Play() error {

cacheData, cacheHit := cache.PodcastPlayedCache.Get(defaultPodcastCache)
if cacheHit {
podcastCache = cacheData.(podcastCacheData) //nolint:forcetypeassert // TODO: type checking
}

if p.EpisodeGUID != "" {
podcastCache.Guids = append(podcastCache.Guids, p.EpisodeGUID)
_, ok := cacheData.(podcastCacheData)
if ok {
podcastCache = cacheData.(podcastCacheData)

if p.EpisodeGUID != "" {
podcastCache.Guids = append(podcastCache.Guids, p.EpisodeGUID)
}
}
}

err := p.setCache(&podcastCache)
Expand Down
11 changes: 9 additions & 2 deletions content/podcast_episodes_internal.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (

"github.com/jmillerv/go-dj/cache"
"github.com/mmcdole/gofeed"
log "github.com/sirupsen/logrus"
)

type podcasts struct {
Expand Down Expand Up @@ -38,10 +39,16 @@ func (p *podcasts) getNewestEpisode() episode {
for i, ep := range p.Episodes {
// check for cacheData cache
cacheData, cacheHit := cache.PodcastPlayedCache.Get(defaultPodcastCache)
log.WithField("data", cacheData).WithField("hit", cacheHit).Info("cache data")

if cacheHit {
retrieved := (&podcastCacheData{}).fromCache(cacheData) //nolint:exhaustruct // need type casting
if contains(retrieved.Guids, ep.GUID) {
continue

// check for nil retrieved guids
if retrieved != nil {
if contains(retrieved.Guids, ep.GUID) {
continue
}
}
}

Expand Down
12 changes: 9 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,15 @@ func main() { //nolint:funlen,cyclop // main function can be longer & more compl
UsageText: "deletes the in memory and locally saved podcast cache",
Action: func(c *cli.Context) {
log.Info("clearing cache")
scheduler, err := content.NewScheduler(configFile)

// set the config
var config string
if os.Getenv(configOverride) != "" {
config = os.Getenv(configOverride)
} else {
config = configFile
}
scheduler, err := content.NewScheduler(config)
if err != nil {
log.WithError(err).Error("content.NewScheduler::unable to create scheduler from config file")
}
Expand All @@ -111,8 +119,6 @@ func main() { //nolint:funlen,cyclop // main function can be longer & more compl
// create cache
cache.PodcastPlayedCache = zcache.New(ttl, ttl)

// hydrate podcast
content.HydratePodcastCache()
err = cache.ClearPodcastPlayedCache()
if err != nil {
log.WithError(err).Error("unable to clear podcast played cache")
Expand Down
2 changes: 1 addition & 1 deletion taskfile.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ tasks:
run:
cmds:
- task: build
- ./go-dj --help
- ./go-dj s

# Lints go-dj
lint:
Expand Down

0 comments on commit 285af88

Please sign in to comment.