mirror of
				https://github.com/ruby/ruby.git
				synced 2022-11-09 12:17:21 -05:00 
			
		
		
		
	webrick/httpauth/htgroup.rb (flush): avoid unnecessary unlink
Based on patch by akr [ruby-core:88477], use Tempfile.create to avoid unnecessary unlink call. Unlike akr's original patch, this does not change the return value of flush. Thanks-to: Tanaka Akira <akr@fsij.org> git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64363 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
		
							parent
							
								
									7d664ecc49
								
							
						
					
					
						commit
						ab7e34e4db
					
				
					 1 changed files with 7 additions and 4 deletions
				
			
		| 
						 | 
				
			
			@ -63,15 +63,18 @@ module WEBrick
 | 
			
		|||
 | 
			
		||||
      def flush(output=nil)
 | 
			
		||||
        output ||= @path
 | 
			
		||||
        tmp = Tempfile.new("htgroup", File::dirname(output))
 | 
			
		||||
        tmp = Tempfile.create("htgroup", File::dirname(output))
 | 
			
		||||
        begin
 | 
			
		||||
          @group.keys.sort.each{|group|
 | 
			
		||||
            tmp.puts(format("%s: %s", group, self.members(group).join(" ")))
 | 
			
		||||
          }
 | 
			
		||||
        ensure
 | 
			
		||||
          tmp.close
 | 
			
		||||
          File::rename(tmp.path, output)
 | 
			
		||||
        rescue
 | 
			
		||||
          tmp.close(true)
 | 
			
		||||
          if $!
 | 
			
		||||
            File.unlink(tmp.path)
 | 
			
		||||
          else
 | 
			
		||||
            return File.rename(tmp.path, output)
 | 
			
		||||
          end
 | 
			
		||||
        end
 | 
			
		||||
      end
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue