HomePhorge

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

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>
(cherry picked from commit 3aec02ba0e4bda8ba4e9fffbc6defaae4e4e2ba1)

Details

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

Event Timeline

Jacob Helwig <jacob@puppetlabs.com> committed rPU4a6d61717eb5: Consolidate test logic determining if a registered file is in the temp directory (authored by Jacob Helwig <jacob@puppetlabs.com>).Aug 19 2011, 10:52 PM