Summary
Currently, free-up-space is computed by using the calculate-free-up-space.sh bash script. While this works, we lose out on a few key benefits by not having this logic run as Swift code:
- Readability: there is less cognitive overhead for contributors if this logic is in Swift, as the rest of the project is.
- Testability: writing unit tests for this logic is significantly easier and more familiar for contributors, as we can engage in typical practices like dependency injection (imagine we leverage
FileManager; we can inject a mock to unit test the logic).
- Parallelism: anecdotally, I have noticed that this operation takes quite some time. We iterate over every file in the list of directories we want to clean. Doing these operations in parallel may significantly reduce the time it takes to compute free-up-space.
Proposed Solution
Convert this script to Swift, add unit tests, and leverage parallelism in Swift Concurrency to speed up this operation.
Summary
Currently, free-up-space is computed by using the
calculate-free-up-space.shbash script. While this works, we lose out on a few key benefits by not having this logic run as Swift code:FileManager; we can inject a mock to unit test the logic).Proposed Solution
Convert this script to Swift, add unit tests, and leverage parallelism in Swift Concurrency to speed up this operation.