Skip to content

Commit

Permalink
handle forking, which previously led to the same random numbers (and …
Browse files Browse the repository at this point in the history
…therefore tmpdirs) being generated
  • Loading branch information
seamusabshere committed Mar 30, 2011
1 parent 6d7f758 commit 9d0d998
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions lib/remote_table/executor.rb
Expand Up @@ -7,6 +7,7 @@ class RemoteTable
class Executor
include ::Singleton
def bang(path, cmd)
srand # in case this was forked by resque
tmp_path = "#{path}.bang.#{rand}"
backtick_with_reporting "cat #{::Escape.shell_single_word path} | #{cmd} > #{::Escape.shell_single_word tmp_path}"
::FileUtils.mv tmp_path, path
Expand Down
1 change: 1 addition & 0 deletions lib/remote_table/format/fixed_width.rb
Expand Up @@ -25,6 +25,7 @@ def definition
::Slither.send :definition, t.properties.schema_name
elsif t.properties.schema.is_a?(::Array)
everything = lambda { |_| true }
srand # in case this was forked by resque
::Slither.define(rand.to_s) do |d|
d.rows do |row|
row.trap(&everything)
Expand Down
1 change: 1 addition & 0 deletions lib/remote_table/properties.rb
Expand Up @@ -212,6 +212,7 @@ def format

def staging_dir_path #:nodoc:
return @staging_dir_path if @staging_dir_path.is_a?(::String)
srand # in case this was forked by resque
@staging_dir_path = ::File.join ::Dir.tmpdir, 'remote_table_gem', rand.to_s
::FileUtils.mkdir_p @staging_dir_path
@staging_dir_path
Expand Down
2 changes: 1 addition & 1 deletion lib/remote_table/version.rb
@@ -1,3 +1,3 @@
class RemoteTable
VERSION = "1.1.3"
VERSION = "1.1.4"
end

0 comments on commit 9d0d998

Please sign in to comment.