On Aug 6, 2009, at 2:59 PM, Markus Roberts wrote:

>
> Added a random suffex to the temporary file name and verify that
>    the name is not in use (retry on collison).  No additional
>    tests added as the lifetime of the temporary file is bound by
>    the routine, making spec driven tests impraticable.

You could do an 'expect' on which file we open, but... yeah, it  
quickly has diminishing returns.

The only question I have is whether we can settle for File.exists? or  
if we should do an lstat.  Comments?

>
> Signed-off-by: Markus Roberts <[email protected]>
> ---
> lib/puppet/type/file.rb |    7 +++++--
> 1 files changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/lib/puppet/type/file.rb b/lib/puppet/type/file.rb
> index 0fc2c96..66ca3b3 100644
> --- a/lib/puppet/type/file.rb
> +++ b/lib/puppet/type/file.rb
> @@ -722,8 +722,11 @@ module Puppet
>             remove_existing(:file)
>
>             use_temporary_file = (content.length != 0)
> -            path = self[:path]
> -            path += ".puppettmp" if use_temporary_file
> +            if use_temporary_file
> +                path = "#{self[:path]}.puppettmp_#{rand(10000)}"  
> until !File.exists?(path)
> +              else
> +                path = self[:path]
> +              end
>
>             mode = self.should(:mode) # might be nil
>             umask = mode ? 000 : 022
> -- 
> 1.6.0.4
>
>
> >


-- 
If I want your opinion, I'll read your entrails.
     --Doug Shewfelt
---------------------------------------------------------------------
Luke Kanies | http://reductivelabs.com | http://madstop.com


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Puppet Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/puppet-dev?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to