Bugs arising from encoding one logical operation as two operations
Description
In --dry-run, if a template is supposed to be deleted and then created again with another target, it reports that as a cache corruption because it didn't actually delete the file.
Reproduction
Run with following file mapping:
foo = "bar"
Then run with following with --dry-run:
foo = "baz"
Similar bugs happen for any case where a file is first deleted then created again - for example, swapping a template to a symlink during a dry run
To solve this I'd probably need to restructure my deployment logic a bit and add a concept of "replace_template" and "replace_symlink", of course while handling all the edge cases. I might need to rewrite FileState again for this too - it can be backed by a map
False negative case:
Going from empty to foo = "bar"; baz = "bar" should produce an "already exists" error but doesn't because file doesn't actually exist so it happily "creates" both
The cases described previously are now fixed, but there's a new case:
Start with template a -> b deployed, modify b's contents, swap a -> b to symlink.
Now the deletion of the template is correctly skipped, but in a perfect world the creation of the symlink should not even be attempted.
The same will happen with a target location change