From: <jh...@us...> - 2012-04-27 01:50:15
|
Revision: 327 http://etch.svn.sourceforge.net/etch/?rev=327&view=rev Author: jheiss Date: 2012-04-27 01:50:09 +0000 (Fri, 27 Apr 2012) Log Message: ----------- When passing a params key to Rails for possible storage in the database (various find_or_create_by_* calls), dup the key. This eliminates intermittent "RuntimeError: can't modify frozen String" errors I was getting from the test suite. The wisdom of the Internets seems to indicate that a hash key (all hash keys? or just params hash keys? it's not clear) can be or always are frozen, and thus dup'ing the key fixes the problem. It's a little strange that it's an intermittent problem, but the dup fix seems fairly cheap and harmless. Modified Paths: -------------- trunk/server/lib/etch/server.rb Modified: trunk/server/lib/etch/server.rb =================================================================== --- trunk/server/lib/etch/server.rb 2012-04-27 01:44:06 UTC (rev 326) +++ trunk/server/lib/etch/server.rb 2012-04-27 01:50:09 UTC (rev 327) @@ -231,7 +231,7 @@ # Update the stored facts for this client @client = Client.find_or_create_by_name(@fqdn) @facts.each do |key, value| - fact = Fact.find_or_create_by_client_id_and_key(:client_id => @client.id, :key => key, :value => value) + fact = Fact.find_or_create_by_client_id_and_key(:client_id => @client.id, :key => key.dup, :value => value) if fact.value != value fact.update_attributes(:value => value) end @@ -326,7 +326,7 @@ end request[:files][name][:orig] = origpath # Update the stored record of the original - original = Original.find_or_create_by_client_id_and_file(:client_id => @client.id, :file => name, :sum => sha1) + original = Original.find_or_create_by_client_id_and_file(:client_id => @client.id, :file => name.dup, :sum => sha1) if original.sum != sha1 original.update_attributes(:sum => sha1) end @@ -334,7 +334,7 @@ if filehash['sha1sum'] sha1 = filehash['sha1sum'] # Update the stored record of the original - original = Original.find_or_create_by_client_id_and_file(:client_id => @client.id, :file => name, :sum => sha1) + original = Original.find_or_create_by_client_id_and_file(:client_id => @client.id, :file => name.dup, :sum => sha1) if original.sum != sha1 original.update_attributes(:sum => sha1) end @@ -379,7 +379,7 @@ # setup and depend elements that we send to the client to ensure it # supplies a proper orig file. if !response[:need_orig][file] - config = EtchConfig.find_or_create_by_client_id_and_file(:client_id => @client.id, :file => file, :config => config_xml.to_s) + config = EtchConfig.find_or_create_by_client_id_and_file(:client_id => @client.id, :file => file.dup, :config => config_xml.to_s) if config.config != config_xml.to_s config.update_attributes(:config => config_xml.to_s) end @@ -429,7 +429,7 @@ commands_xml = Etch.xmlnewelem('allcommands', response_xml) response[:allcommands].each do |commandname, command_xml| # Update the stored record of the command - config = EtchConfig.find_or_create_by_client_id_and_file(:client_id => @client.id, :file => commandname, :config => command_xml.to_s) + config = EtchConfig.find_or_create_by_client_id_and_file(:client_id => @client.id, :file => commandname.dup, :config => command_xml.to_s) if config.config != command_xml.to_s config.update_attributes(:config => command_xml.to_s) end This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |