Class: SmartS3Sync::FileTarget
- Inherits:
-
Object
- Object
- SmartS3Sync::FileTarget
- Defined in:
- lib/smart_s3_sync/file_target.rb
Instance Attribute Summary collapse
-
#destinations ⇒ Object
readonly
Returns the value of attribute destinations.
-
#digest ⇒ Object
readonly
Returns the value of attribute digest.
-
#local_source ⇒ Object
readonly
Returns the value of attribute local_source.
-
#remote_filename ⇒ Object
readonly
Returns the value of attribute remote_filename.
-
#size ⇒ Object
readonly
Returns the value of attribute size.
Instance Method Summary collapse
- #add_destination(file) ⇒ Object
- #copy!(fog_dir, sync_options = {}) ⇒ Object
-
#initialize(digest, remote_filename, size) ⇒ FileTarget
constructor
A new instance of FileTarget.
Constructor Details
#initialize(digest, remote_filename, size) ⇒ FileTarget
Returns a new instance of FileTarget.
8 9 10 11 12 13 14 |
# File 'lib/smart_s3_sync/file_target.rb', line 8 def initialize(digest, remote_filename, size) @digest = digest @size = size @remote_filename = remote_filename @local_source = nil @destinations = [] end |
Instance Attribute Details
#destinations ⇒ Object (readonly)
Returns the value of attribute destinations.
6 7 8 |
# File 'lib/smart_s3_sync/file_target.rb', line 6 def destinations @destinations end |
#digest ⇒ Object (readonly)
Returns the value of attribute digest.
6 7 8 |
# File 'lib/smart_s3_sync/file_target.rb', line 6 def digest @digest end |
#local_source ⇒ Object (readonly)
Returns the value of attribute local_source.
6 7 8 |
# File 'lib/smart_s3_sync/file_target.rb', line 6 def local_source @local_source end |
#remote_filename ⇒ Object (readonly)
Returns the value of attribute remote_filename.
6 7 8 |
# File 'lib/smart_s3_sync/file_target.rb', line 6 def remote_filename @remote_filename end |
#size ⇒ Object (readonly)
Returns the value of attribute size.
6 7 8 |
# File 'lib/smart_s3_sync/file_target.rb', line 6 def size @size end |
Instance Method Details
#add_destination(file) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/smart_s3_sync/file_target.rb', line 16 def add_destination(file) unless destinations.include?(file) # If we already have a local file with the right checksum, # we don't add it to the list of destinations and instead # mark it as a local source. if File.exists?(file) && file_hash(file) == digest.to_s add_local_source(file) else destinations.push(file) end end end |
#copy!(fog_dir, sync_options = {}) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/smart_s3_sync/file_target.rb', line 29 def copy!(fog_dir, ={}) # If every copy in the cloud is already present, the # number of destinations will be 0 - there is no work # left to do. if destinations.length > 0 if local_source.nil? # we prefer to not have to download copy_from_fog(fog_dir, ) else copy_from_local(local_source, ) end end end |