This feature is usually called UNWIND-PROTECT in Lisp. You might want to check it out.
Hm, I’m actually a little curious about using CRC instead of a strong crypto hash of some kind. On the one hand, CRC is for integrity, not uniqueness, so collisions will happen. On the other hand, if the cost of a collision is rebuilding a file when it doesn’t need to be, that is not ideal but won’t break anything. The real danger is that the CRC will not detect a change and not rebuild a file that needs to be rebuilt, but in that case modification times should cover it sufficiently.
Anyone have any wisdom about this? I would expect CRC to be potentially rather faster than SHA-256 or something, but don’t have any actual information on how robust it is in practice for file change detection rather than catching single-bit errors.