HomePhorge

Use Win32 API atomic replace in `replace_file`
a257105acb4bUnpublished

Unpublished Commit ยท Learn More

Repository Importing: This repository is still importing.

Description

Use Win32 API atomic replace in replace_file

The changes to enable Windows support in replace_file were not actually
complete, and it didn't work when the file didn't exist - because of
limitations of the emulation done on our side, rather than anything else.

Windows has a bunch of quirks, and Ruby doesn't actually abstract over the
underlying platform a great deal. We can use the Windows API ReplaceFile, and
MoveFileEx, to achieve the desired behaviour though.

This adds even more conditional code inside the replace_file method to
handle multiple platforms - but it really isn't very clean. Better to get
this working now, then refactor, though.

Cherry pick of: 73e302bbf5ab4a6c5513a39070e2c907542775ae

Conflicts:

lib/puppet/util.rb
spec/unit/util_spec.rb

Details

Provenance
Daniel Pittman <daniel@puppetlabs.com>Authored on
Andrew Parker <andy@puppetlabs.com>Committed on Aug 3 2012, 12:32 AM
vanmeeuwenPushed on Jun 2 2015, 2:22 PM
Parents
rPUa619bfd2a519: Add additional commits to CHANGELOG missed in 2.7.19rc1
Branches
Unknown
Tags
Unknown

Event Timeline

Andrew Parker <andy@puppetlabs.com> committed rPUa257105acb4b: Use Win32 API atomic replace in `replace_file` (authored by Daniel Pittman <daniel@puppetlabs.com>).Aug 3 2012, 12:32 AM