Closed alexdmtr closed 5 years ago
That's correct - packages under cmd/
map directly to butler's CLI commands, and are not designed to be used at the API level - after calling butler apply
, butler exits normally and all file handles are closed.
Using the ApplyContext
struct directly lets you have more control over what happens (and, as you noticed, the consumer of that API is in charge of closing the reader).
While investigating how to integrate butler into another project, unit tests reveal that the 'apply' command does not close the handle to the patch file.
Specifically, I believe that in in
cmd/apply/apply.go
patchReader
is never closed.I've attached the following test script; running
Test_Apply
reproduces the issue. The code creates a test environment (NewConfig
) as a temporary folder withold
andnew
"versions" to test patch creation and application. The error occurs inClean
, when the temporary folder cannot be deleted (sincepatch.pwr
is still open by the process)