|
From: <jh...@us...> - 2011-05-04 05:39:03
|
Revision: 276
http://etch.svn.sourceforge.net/etch/?rev=276&view=rev
Author: jheiss
Date: 2011-05-04 05:38:57 +0000 (Wed, 04 May 2011)
Log Message:
-----------
Find.find in ruby 1.9 doesn't like being called with a non-existent
target. So check that directories exist before calling Find.find
against them.
Fix a few "shadowing outer local variable" warnings from ruby 1.9
Modified Paths:
--------------
trunk/client/etchclient.rb
trunk/server/lib/etch.rb
Modified: trunk/client/etchclient.rb
===================================================================
--- trunk/client/etchclient.rb 2011-05-04 05:37:12 UTC (rev 275)
+++ trunk/client/etchclient.rb 2011-05-04 05:38:57 UTC (rev 276)
@@ -29,6 +29,7 @@
require 'fcntl' # Fcntl::O_*
require 'etc' # getpwnam, getgrnam
require 'tempfile' # Tempfile
+require 'find' # Find.find
require 'cgi'
require 'timeout'
require 'logger'
@@ -1803,7 +1804,7 @@
puts "Original file #{file} doesn't exist, saving that state permanently as #{origpath}"
end
if proceed
- File.open(origpath, 'w') { |file| } if (!@dryrun)
+ File.open(origpath, 'w') { |origfile| } if (!@dryrun)
end
end
@@ -2014,7 +2015,7 @@
else
# If there's no file to back up then leave a marker file so
# that restore_backup does the right thing
- File.open("#{backuppath}.NOORIG", "w") { |file| }
+ File.open("#{backuppath}.NOORIG", "w") { |markerfile| }
end
end
@@ -2375,7 +2376,7 @@
begin
fd = IO::sysopen(lockpath, Fcntl::O_WRONLY|Fcntl::O_CREAT|Fcntl::O_EXCL)
puts "Lock acquired for #{file}" if (@debug)
- f = IO.open(fd) { |f| f.puts $$ }
+ f = IO.open(fd) { |lockfile| lockfile.puts $$ }
@locked_files[file] = true
return
rescue Errno::EEXIST
@@ -2420,13 +2421,15 @@
# and can be removed. If told to force we remove all lockfiles.
def remove_stale_lock_files
twohoursago = Time.at(Time.now - 60 * 60 * 2)
- Find.find(@lockbase) do |file|
- next unless file =~ /\.LOCK$/
- next unless File.file?(file)
-
- if @lockforce || File.mtime(file) < twohoursago
- puts "Removing stale lock file #{file}"
- File.delete(file)
+ if File.exist?(@lockbase)
+ Find.find(@lockbase) do |file|
+ next unless file =~ /\.LOCK$/
+ next unless File.file?(file)
+
+ if @lockforce || File.mtime(file) < twohoursago
+ puts "Removing stale lock file #{file}"
+ File.delete(file)
+ end
end
end
end
Modified: trunk/server/lib/etch.rb
===================================================================
--- trunk/server/lib/etch.rb 2011-05-04 05:37:12 UTC (rev 275)
+++ trunk/server/lib/etch.rb 2011-05-04 05:38:57 UTC (rev 276)
@@ -170,10 +170,12 @@
filelist = []
if request.empty?
@dlogger.debug "Building complete file list for request from #{@fqdn}"
- Find.find(@sourcebase) do |path|
- if File.directory?(path) && File.exist?(File.join(path, 'config.xml'))
- # Strip @sourcebase from start of path
- filelist << path.sub(Regexp.new('^' + Regexp.escape(@sourcebase)), '')
+ if File.exist?(@sourcebase)
+ Find.find(@sourcebase) do |path|
+ if File.directory?(path) && File.exist?(File.join(path, 'config.xml'))
+ # Strip @sourcebase from start of path
+ filelist << path.sub(Regexp.new('^' + Regexp.escape(@sourcebase)), '')
+ end
end
end
elsif request[:files]
@@ -206,9 +208,11 @@
commandnames = []
if request.empty?
@dlogger.debug "Building complete configuration commands for request from #{@fqdn}"
- Find.find(@commandsbase) do |path|
- if File.directory?(path) && File.exist?(File.join(path, 'commands.xml'))
- commandnames << File.basename(path)
+ if File.exist?(@commandsbase)
+ Find.find(@commandsbase) do |path|
+ if File.directory?(path) && File.exist?(File.join(path, 'commands.xml'))
+ commandnames << File.basename(path)
+ end
end
end
elsif request[:commands]
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|