Skip to content

Commit

Permalink
Additional nil checks
Browse files Browse the repository at this point in the history
  • Loading branch information
irees committed Jan 24, 2025
1 parent 13ba616 commit cdd01b2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
3 changes: 3 additions & 0 deletions finders/dbfinder/finder.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,9 @@ func (f *Finder) FindFeedVersionServiceWindow(ctx context.Context, fvid int) (*m
if err != nil {
return nil, err
}
if a == nil {
return nil, errors.New("no service window found")
}
// Get local time
nowLocal := time.Now().In(a.Location)
if model.ForContext(ctx).Clock != nil {
Expand Down
6 changes: 3 additions & 3 deletions internal/clock/swcache.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,19 @@ type ServiceWindow struct {
type ServiceWindowCache struct {
db sqlx.Ext
lock sync.Mutex
fvslWindows map[int]ServiceWindow
fvslWindows map[int]*ServiceWindow
tzCache *tzcache.Cache[int]
}

func NewServiceWindowCache(db sqlx.Ext) *ServiceWindowCache {
return &ServiceWindowCache{
db: db,
fvslWindows: map[int]ServiceWindow{},
fvslWindows: map[int]*ServiceWindow{},
tzCache: tzcache.NewCache[int](),
}
}

func (f *ServiceWindowCache) Get(ctx context.Context, fvid int) (ServiceWindow, bool, error) {
func (f *ServiceWindowCache) Get(ctx context.Context, fvid int) (*ServiceWindow, bool, error) {
f.lock.Lock()
defer f.lock.Unlock()
a, ok := f.fvslWindows[fvid]
Expand Down

0 comments on commit cdd01b2

Please sign in to comment.