Class: StaticSync::Storage
- Inherits:
-
Object
- Object
- StaticSync::Storage
- Defined in:
- lib/static_sync/storage.rb
Instance Method Summary collapse
-
#initialize(config) ⇒ Storage
constructor
A new instance of Storage.
- #sync ⇒ Object
Constructor Details
Instance Method Details
#sync ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/static_sync/storage.rb', line 14 def sync verify_remote_directory remote_keys = [] remote_directory.files.each do |file| remote_keys << [file.key, file.etag] end log.info("Synching #{@config.source} to #{@config.target}.") if @config.log Dir.chdir(@config.source) do local_filtered_files.each do |file| current_file = @meta.for(file) current_file_key = [current_file[:key], current_file[:etag]] unless remote_keys.include?(current_file_key) log.info("Uploading #{file}") if @config.log begin remote_directory.files.create(current_file) rescue => error log.error("Failed to upload #{file}") raise error end end end log.info("Synching done.") if @config.log end end |