abcxyz / abc

Apache License 2.0
12 stars 3 forks source link

fix: missing directory during patch reversal #621

Closed drevell closed 2 months ago

drevell commented 2 months ago

When abc is upgrading a manifest that uses the "include from destination" feature (aka modify destination files in place), one step in the the upgrade process is to undo the template's previous modifications to such files. We do this by applying each patch from the manifest, and saving the patched files in a temp directory.

The bug occurs when the file being patched is not in the root of the destination, but in a subdirectory. Since the directory structure of the abovementioned temp directory mirrors that of the destination directory, we try to output the patched file into the appropriate subdirectory. However, due to this bug, nothing ever created subdirectories in the temp dir, so this write would fail whenever the file being patched is not in the root of the destination.

So basically patch reversal was broken except for the narrow case where the file being patched was in the root of the destination.

The fix is just to add a MkdirAll call.