Method: Filezor::Client#sync
- Defined in:
- lib/filezor/client.rb
#sync(*files) ⇒ Object
This method acts like an rsync –delete. It deletes all files in the root, and then puts the new files in. TODO: make atomic
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/filezor/client.rb', line 30 def sync(*files) = files.last.is_a?(Hash) ? files.pop : {} files = files.flatten.uniq test(files) # # files.each do |f| # f.path = File.join(root, f.path) # end cached_md5s = caching? ? Set.new(cached(files)) : [] params = files.inject({}) do |memo, file| memo[file.path] = cached_md5s.include?(file.md5) ? file.md5 : file.tempfile memo end params["--delete"] = [:delete] if [:delete] params["--root"] = [:root] if [:root] post("", params) end |