Skip to content

Commit

Permalink
Clear guesses after add/remove
Browse files Browse the repository at this point in the history
  • Loading branch information
blast-hardcheese committed Jan 2, 2024
1 parent e6be876 commit 1132e8c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
2 changes: 2 additions & 0 deletions internal/cli/cmds.go
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,7 @@ func runAdd(
maybeInstall(ctx, b, forceInstall)
}

store.ClearGuesses(ctx, b)
store.UpdateFileHashes(ctx, b)
store.Write(ctx)
}
Expand Down Expand Up @@ -415,6 +416,7 @@ func runRemove(language string, args []string, upgrade bool,
maybeInstall(ctx, b, forceInstall)
}

store.ClearGuesses(ctx, b)
store.UpdateFileHashes(ctx, b)
store.Write(ctx)
}
Expand Down
10 changes: 10 additions & 0 deletions internal/store/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,16 @@ func GuessWithCache(ctx context.Context, b api.LanguageBackend, forceGuess bool)
}
}

func ClearGuesses(ctx context.Context, b api.LanguageBackend) {
span, ctx := tracer.StartSpanFromContext(ctx, "ClearGuesses")
defer span.Finish()

cache := getLanguageCache(b.Name, b.Alias)

cache.GuessedImports = nil
cache.GuessedImportsHash = ""
}

// UpdateFileHashes caches the current states of the specfile and
// lockfile. Neither file need exist.
func UpdateFileHashes(ctx context.Context, b api.LanguageBackend) {
Expand Down

0 comments on commit 1132e8c

Please sign in to comment.