Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.