Skip to content

Commit

Permalink
Merge #7031
Browse files Browse the repository at this point in the history
7031: Fix crates local index state updates r=Undin a=avrong

Bug introduced by changes in #6898. Using `val` for a state field doesn't make it possible to serialize and save it, so it was being ignored.

changelog: Fix unnecessary reload of crates local index after IDE restart.


Co-authored-by: Aleksei Trifonov <avrong@avrong.me>
  • Loading branch information
bors[bot] and avrong committed Apr 3, 2021
2 parents 47c7aee + d22e2b0 commit 8fd4604
Showing 1 changed file with 4 additions and 2 deletions.
Expand Up @@ -49,8 +49,10 @@ import java.util.concurrent.atomic.AtomicBoolean
/**
* Crates local index, created from user cargo registry index on host machine.
* Used for dependency code insight in project's `Cargo.toml`.
*
* Stores crates info in [crates] persistent hash map and hash for commit which has been used for index load in
* persistent state [CratesLocalIndexState].
* persistent state [CratesLocalIndexState]. Note, state's properties should be mutable in order to be serialized and
* saved.
*/
@State(name = "CratesLocalIndexState", storages = [Storage("rust.crateslocalindex.xml")])
class CratesLocalIndexServiceImpl
Expand Down Expand Up @@ -273,7 +275,7 @@ class CratesLocalIndexServiceImpl
}

companion object {
data class CratesLocalIndexState(val indexedCommitHash: String = "")
data class CratesLocalIndexState(var indexedCommitHash: String = "")

private val corruptionMarkerFile: Path
get() = baseCratesLocalRegistryDir.resolve(CORRUPTION_MARKER_NAME)
Expand Down

0 comments on commit 8fd4604

Please sign in to comment.