Artifact cache file can get significantly inaccurate
Summary
If BuildStream terminates unexpectedly when an artifact commit, artifact pull or artifact clean operation is in progress, the cache size file stored can get significantly inaccurate, as unaccounted objects could have been added or removed. This would be particularly problematic with large-sized artifacts.
Steps to reproduce
kill -9 $(buildstream-pid) during one of the unsafe operations.
What is the current bug behavior?
The cache size won't be coherent on unexpected terminations.
What is the expected correct behavior?
The cache size file is always coherent.
Possible fixes
- Before committing an artifact, pulling an artifact or cleaning an artifact, unlink cache size file from the disk.
- After these operations complete, write back cache size to the disk.
Edited by Tiago Gomes