Skip to content

Commit

Permalink
UpdateFileHashes doesn't convey that it also initializes the cache
Browse files Browse the repository at this point in the history
  • Loading branch information
blast-hardcheese committed Jan 3, 2024
1 parent 1132e8c commit ff8a787
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
4 changes: 4 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.Read(ctx, b)
store.ClearGuesses(ctx, b)
store.UpdateFileHashes(ctx, b)
store.Write(ctx)
Expand Down Expand Up @@ -416,6 +417,7 @@ func runRemove(language string, args []string, upgrade bool,
maybeInstall(ctx, b, forceInstall)
}

store.Read(ctx, b)
store.ClearGuesses(ctx, b)
store.UpdateFileHashes(ctx, b)
store.Write(ctx)
Expand All @@ -437,6 +439,7 @@ func runLock(language string, upgrade bool, forceLock bool, forceInstall bool) {
maybeInstall(ctx, b, forceInstall)
}

store.Read(ctx, b)
store.UpdateFileHashes(ctx, b)
store.Write(ctx)
}
Expand All @@ -449,6 +452,7 @@ func runInstall(language string, force bool) {

maybeInstall(ctx, b, force)

store.Read(ctx, b)
store.UpdateFileHashes(ctx, b)
store.Write(ctx)
}
Expand Down
11 changes: 8 additions & 3 deletions internal/store/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -218,14 +218,19 @@ func ClearGuesses(ctx context.Context, b api.LanguageBackend) {
cache.GuessedImportsHash = ""
}

func Read(ctx context.Context, b api.LanguageBackend) {
//nolint:ineffassign,wastedassign,staticcheck
span, ctx := tracer.StartSpanFromContext(ctx, "store.Read")
defer span.Finish()
readMaybe()
initLanguage(b.Name, b.Alias)
}

// UpdateFileHashes caches the current states of the specfile and
// lockfile. Neither file need exist.
func UpdateFileHashes(ctx context.Context, b api.LanguageBackend) {
//nolint:ineffassign,wastedassign,staticcheck
span, ctx := tracer.StartSpanFromContext(ctx, "store.UpdateFileHashes")
defer span.Finish()
readMaybe()
initLanguage(b.Name, b.Alias)
cache := getLanguageCache(b.Name, b.Alias)
cache.SpecfileHash = hashFile(b.Specfile)
cache.LockfileHash = hashFile(b.Lockfile)
Expand Down

0 comments on commit ff8a787

Please sign in to comment.