Function cargo::sources::git::utils::clean_repo_temp_files

source ·
fn clean_repo_temp_files(repo: &Repository)
Expand description

Removes temporary files left from previous activity.

If libgit2 is interrupted while indexing pack files, it will leave behind some temporary files that it doesn’t clean up. These can be quite large in size, so this tries to clean things up.

This intentionally ignores errors. This is only an opportunistic cleaning, and we don’t really care if there are issues (there’s unlikely anything that can be done).

The git CLI has similar behavior (its temp files look like objects/pack/tmp_pack_9kUSA8). Those files are normally deleted via git prune which is run by git gc. However, it doesn’t know about libgit2’s filenames, so they never get cleaned up.