lib/pave/files.rb in pave-0.14.0 vs lib/pave/files.rb in pave-0.14.1
- old
+ new
@@ -1,28 +1,35 @@
module Pave
class Files
include Pave::Shell
+ def self.exclusions
+ " --exclude 'files/tmp' --exclude 'files/cache' "
+ end
+
+ def self.flags
+ " -uazh -e ssh --progress "
+ end
+
def self.clear_cache
sh "rm -rf ./files/tmp/*; rm -rf ./files/cache/*;"
end
def self.push(remote="live")
- clear_cache
server = Pave::Remote.server(remote)
directory = Pave::Remote.directory(remote)
- sh "scp -r ./files #{server}:#{directory}/local_files;"
- sh "ssh #{server} 'cd #{directory};
- mv ./files ./old_files;
- mv ./local_files ./files && rm -rf ./old_files;'"
+ sh "rsync #{flags} #{exclusions} ./files/* #{server}:#{directory}/files/*"
end
def self.pull(remote="live")
server = Pave::Remote.server(remote)
directory = Pave::Remote.directory(remote)
- sh "scp -r #{server}:#{directory}/files ./remote_files;
- mv ./files ./old_files;
- mv ./remote_files ./files && rm -rf ./old_files;"
+ sh "rsync #{flags} #{exclusions} #{server}:#{directory}/files/* ./files/*"
clear_cache
+ end
+
+ def self.sync(remote="live")
+ pull(remote)
+ push(remote)
end
end
end