lib/scout/tmpfile.rb in scout-gear-7.3.0 vs lib/scout/tmpfile.rb in scout-gear-8.0.0

- old
+ new

@@ -91,33 +91,32 @@ yield dir end end end + SLASH_REPLACE = 'ยท' def self.tmp_for_file(file, tmp_options = {}, other_options = {}) - tmp_for_file = IndiferentHash.process_options tmp_options, :file + tmp_for_file, prefix, key, persistence_dir = IndiferentHash.process_options tmp_options, :file, :prefix, :key, :dir return tmp_for_file unless tmp_for_file.nil? - prefix = IndiferentHash.process_options tmp_options, :prefix - if prefix.nil? - perfile = file.to_s.gsub(/\//, '>') + perfile = file.to_s.sub(/\.b?gz$/,'') else - perfile = prefix.to_s + ":" + file.to_s.gsub(/\//, '>') + perfile = prefix.to_s + ":" + file.to_s.sub(/\.b?gz$/,'') end - perfile.sub!(/\.b?gz$/,'') + perfile += "[#{ key }]" if key if other_options.include? :filters other_options[:filters].each do |match,value| perfile = perfile + "&F[#{match}=#{Misc.digest(value)}]" end end - persistence_dir = IndiferentHash.process_options(tmp_options, :dir) || TmpFile.tmpdir + persistence_dir = TmpFile.tmpdir if persistence_dir.nil? Path.setup(persistence_dir) unless Path === persistence_dir - filename = perfile.gsub(/\s/,'_').gsub(/\//,'>') + filename = perfile.gsub(/\s/,'_').gsub('/', SLASH_REPLACE) clean_options = other_options.dup clean_options.delete :unnamed clean_options.delete "unnamed" filename = filename[0..MAX_FILE_LENGTH] << Misc.digest(filename[MAX_FILE_LENGTH+1..-1]) if filename.length > MAX_FILE_LENGTH + 10