File tree Expand file tree Collapse file tree 3 files changed +13
-11
lines changed
Expand file tree Collapse file tree 3 files changed +13
-11
lines changed Original file line number Diff line number Diff line change @@ -22,17 +22,19 @@ func Run(cfg *config.Config) error {
2222}
2323
2424// scanReposCmd is a command that scans for repositories
25- func scanReposCmd (cfg * config.Config ) tea.Cmd {
25+ // If forceRefresh is true, bypass cache and scan fresh
26+ func scanReposCmd (cfg * config.Config , forceRefresh bool ) tea.Cmd {
2627 return func () tea.Msg {
27- // Try to load from cache first
2828 cacheStore := cache .NewFileStore ()
29- cached , err := cacheStore .Load ()
3029
31- if err == nil && cacheStore .IsValid (cacheMaxAge ) && cacheStore .IsSameRoots (cfg .Roots ) {
32- // Use cached data but trigger background refresh
33- return scanCompleteMsg {
34- repos : cached .Repos ,
35- fromCache : true ,
30+ // Try to load from cache first (unless forcing refresh)
31+ if ! forceRefresh {
32+ cached , err := cacheStore .Load ()
33+ if err == nil && cacheStore .IsValid (cacheMaxAge ) && cacheStore .IsSameRoots (cfg .Roots ) {
34+ return scanCompleteMsg {
35+ repos : cached .Repos ,
36+ fromCache : true ,
37+ }
3638 }
3739 }
3840
Original file line number Diff line number Diff line change @@ -153,7 +153,7 @@ func NewModel(cfg *config.Config) Model {
153153
154154// Init initializes the model
155155func (m Model ) Init () tea.Cmd {
156- return tea .Batch (m .spinner .Tick , scanReposCmd (m .cfg ))
156+ return tea .Batch (m .spinner .Tick , scanReposCmd (m .cfg , false ))
157157}
158158
159159// GetSelectedRepo returns the currently selected repo
Original file line number Diff line number Diff line change @@ -110,7 +110,7 @@ func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
110110 } else {
111111 m .statusMsg = ""
112112 }
113- return m , scanReposCmd (m .cfg )
113+ return m , scanReposCmd (m .cfg , true )
114114
115115 case grassDataLoadedMsg :
116116 m .grassData = msg .data
@@ -182,7 +182,7 @@ func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
182182 case "r" :
183183 m .state = StateLoading
184184 m .statusMsg = "Rescanning..."
185- return m , scanReposCmd (m .cfg )
185+ return m , scanReposCmd (m .cfg , true )
186186
187187 case "f" :
188188 // Cycle through filter modes
You can’t perform that action at this time.
0 commit comments