[minor] Now explicitly closes cache files after write operation.
#25231 Added additional error checking around node insertion.
This adds a check to ensure that all existing leaf nodes in the tree
actually have correct shotgun data associated. There seeme to be some
sort of edge case (which we have not yet been able to reproduce) where
existing leaf nodes in the tree don't have associated shotgun data. This
fix detects such nodes and emits a warning message - previously it would
instead raise an error message and stop execution.