HomePhorge

Consolidate test logic determining if a registered file is in the temp directory
3aec02ba0e4bUnpublished

Unpublished Commit ยท Learn More

Repository Importing: This repository is still importing.

Description

Consolidate test logic determining if a registered file is in the temp directory

Previously, we were always using string comparisons, and hard-coded
paths to temp locations on non-Windows platforms. This was
problematic for a few reasons. We had to maintain a list of temp
locations for the various platforms, and the string comparisons were
unreliable on Windows, since paths have two string representations
(the "short" name containing a ~ followed by a number, and the "full"
name).

By getting the current temp location using Dir.tempdir (the same
mechanism our temp creation code uses), we no longer need to maintain
the list of temp locations. Also, rather than doing string
comparisons on file paths, we can use a combination of
Pathname#ascend, and File.identical? to determine if the path
registered as a temp file for deletion was actually created in the
temp location.

With this refactoring, the same code now works for both Windows, and
non-Windows platforms.

Reviewed-by: Nick Lewis <nick@puppetlabs.com>

Details

Provenance
Jacob Helwig <jacob@puppetlabs.com>Authored on
vanmeeuwenPushed on Jun 2 2015, 2:22 PM
Parents
rPUb4cacfd8f955: Clarify logic and error messages when initializing Puppet::FileBucket::File
Branches
Unknown
Tags
Unknown

Event Timeline

Jacob Helwig <jacob@puppetlabs.com> committed rPU3aec02ba0e4b: Consolidate test logic determining if a registered file is in the temp directory (authored by Jacob Helwig <jacob@puppetlabs.com>).Aug 3 2011, 1:33 AM