diff --git a/up.rb b/up.rb index 2484e20..f14dcb4 100755 --- a/up.rb +++ b/up.rb @@ -8,7 +8,7 @@ require 'open-uri' UPLOAD_BASE_PATH = "/home/arachnist/public_html/c/" LINK_BASE_PATH = "https://arachnist.is-a.cat/c/" HOST = "i.am-a.cat" -USER = "arachnist" +USERNAME = "arachnist" ARGV.each do |path| Process.fork { @@ -17,16 +17,14 @@ ARGV.each do |path| ext = "." + path.sub(/.*[.]([^.]*)/, '\1') if path.match(/[^.]+[.][^.]+/) content = open(path).read md5 = Digest::MD5.hexdigest(content) - Net::SCP.start(HOST, USER) do |scp| - # basically a glorified syntax sugar for (ext.nil? ? "" : ext) - begin - scp.upload!(StringIO.new(content), UPLOAD_BASE_PATH + md5 + ext) - # we probably tried to add nil to a string ("ext" could possibly be nil) - rescue TypeError - scp.upload!(StringIO.new(content), UPLOAD_BASE_PATH + md5) - end + # basically a glorified syntax sugar for (ext.nil? ? "" : ext) + begin + Net::SCP.upload!(HOST, USERNAME, StringIO.new(content), UPLOAD_BASE_PATH + md5 + ext) + # we probably tried to add nil to a string ("ext" could possibly be nil) + rescue TypeError + Net::SCP.upload!(HOST, USERNAME, StringIO.new(content), UPLOAD_BASE_PATH + md5) end - printf("%s\n\t=> %s%s%s\n", path, LINK_BASE_PATH, md5, ext) + printf("%s\t=> %s%s%s\n", path, LINK_BASE_PATH, md5, ext) } end