Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TS-2040/] Fix panic and test failure caused by invalid TCLI_HOME index filesystem state #9

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
uses: Swatinem/rust-cache@v2

- name: Build tests
run: cargo test --target ${{ matrix.target }} --no-run
run: cargo test --target ${{ matrix.target }} --no-run -- --test-threads=1

- name: Run tests
run: cargo test --target ${{ matrix.target }} --no-fail-fast
run: cargo test --target ${{ matrix.target }} --no-fail-fast -- --test-threads=1
13 changes: 13 additions & 0 deletions src/package/index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,19 @@ impl PackageIndex {
}

let index_dir = tcli_home.join("index");

let lookup = index_dir.join("lookup.json");
let index = index_dir.join("index.json");
let header = index_dir.join("header.json");

if !index_dir.is_dir() {
fs::create_dir(&index_dir)?;
}

if !lookup.is_file() || !index.is_file() || !header.is_file() {
PackageIndex::sync(tcli_home).await?;
}

let lookup: HashMap<PackageReference, LookupTableEntry> = {
let contents = fs::read_to_string(index_dir.join("lookup.json"))?;
serde_json::from_str(&contents)?
Expand Down
Loading