Skip to content

Instantly share code, notes, and snippets.

@Coro365
Created January 9, 2016 05:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Coro365/6d5ac5e55db77198a8d9 to your computer and use it in GitHub Desktop.
Save Coro365/6d5ac5e55db77198a8d9 to your computer and use it in GitHub Desktop.
require 'fileutils'
#前回upしたものと同じでなければupする
PATH = ""
NAME = File.basename(PATH)
TEMP_NAME = "#{NAME}.sum"
TEMP_DIR = ""
TEMP_PATH = TEMP_DIR + TEMP_NAME
def get_sum
sum = `md5sum #{PATH}`
sum = sum.split("\s\s")
return sum[0]
end
def read_past_sum
Dir.mkdir(TEMP_DIR) unless Dir.exist?(TEMP_DIR)
FileUtils.touch(TEMP_PATH) unless File.exist?(TEMP_PATH)
File.read(TEMP_PATH)
end
def write_sum
File.open(TEMP_PATH,"w") do |f|
f.print SUM
end
end
SUM = get_sum
past_sum = read_past_sum
unless SUM == past_sum
puts "uploading..."
puts `dropbox_uploader.sh upload #{PATH} #{NAME}`
write_sum
else
puts "no diff"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment