Class: Synco::Methods::RSyncSnapshot
Instance Attribute Summary
#arguments, #options
Attributes inherited from Controller
#events
Instance Method Summary
collapse
Methods inherited from RSync
#connect_arguments, #default_command, #escape
Methods inherited from Controller
#abort!, build, #fire, #freeze, #on, #try
Constructor Details
#initialize(*command, arguments: [], archive: true, stats: true, **options) ⇒ RSyncSnapshot
Returns a new instance of RSyncSnapshot.
113
114
115
|
# File 'lib/synco/methods/rsync.rb', line 113
def initialize(*command, arguments: [], archive: true, stats: true, **options)
super
end
|
Instance Method Details
#call(scope) ⇒ Object
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
|
# File 'lib/synco/methods/rsync.rb', line 137
def call(scope)
master_server = scope.master_server
target_server = scope.target_server
directory = scope.directory
incremental_path = compute_incremental_path(directory)
link_arguments = compute_link_arguments(directory, incremental_path)
target_server.run('mkdir', '-p', target_server.full_path(incremental_path))
master_server.run(
*@command,
*@arguments,
*directory.arguments,
*connect_arguments(master_server, target_server),
*link_arguments,
master_server.connection_string(directory, on: master_server),
target_server.connection_string(incremental_path, on: master_server)
)
rescue CommandFailure => failure
raise unless failure.status.to_i == 24
end
|
#compute_incremental_path(directory) ⇒ Object
125
126
127
|
# File 'lib/synco/methods/rsync.rb', line 125
def compute_incremental_path(directory)
File.join(snapshot_name, directory.path)
end
|
#compute_link_arguments(directory, incremental_path) ⇒ Object
129
130
131
132
133
134
135
|
# File 'lib/synco/methods/rsync.rb', line 129
def compute_link_arguments(directory, incremental_path)
depth = Directory.depth(incremental_path)
latest_path = File.join("../" * depth, latest_name, directory.path)
return ['--link-dest', latest_path]
end
|
#latest_name ⇒ Object
121
122
123
|
# File 'lib/synco/methods/rsync.rb', line 121
def latest_name
@options[:latest_name] || LATEST_NAME
end
|
#snapshot_name ⇒ Object
117
118
119
|
# File 'lib/synco/methods/rsync.rb', line 117
def snapshot_name
@options[:snapshot_name] || SNAPSHOT_NAME
end
|