Class: LogicalConstruct::ResolutionServer::States::Unresolved
- Inherits:
-
PlanState
- Object
- PlanState
- LogicalConstruct::ResolutionServer::States::Unresolved
- Defined in:
- lib/logical-construct/target/plan-records.rb
Constant Summary
Constants included from Protocol::PlanValidation
Protocol::PlanValidation::BIG_CHUNK
Instance Attribute Summary
Attributes inherited from PlanState
Instance Method Summary collapse
- #can_receive? ⇒ Boolean
- #enter ⇒ Object (also: #receive)
- #resolve ⇒ Object
- #store_received_file(actual_hash) ⇒ Object
Methods inherited from PlanState
#==, #alive?, #cancel!, #change, #current_path, #current_plans_dir, #delivered_plans_dir, #exists?, #filehash, #initialize, #inspect, #join, #name, #received_path, #resolved?, #state, #storage_path_for, #stored_plans_dir
Methods included from Protocol::PlanValidation
#check_digest, #chunk_size, #digest, #file_checksum, #generate_checksum, #realpath
Constructor Details
This class inherits a constructor from LogicalConstruct::ResolutionServer::States::PlanState
Instance Method Details
#can_receive? ⇒ Boolean
185 186 187 |
# File 'lib/logical-construct/target/plan-records.rb', line 185 def can_receive? true end |
#enter ⇒ Object Also known as: receive
198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 |
# File 'lib/logical-construct/target/plan-records.rb', line 198 def enter unless alive? super return false end unless exists?(received_path) return false end actual_hash = file_checksum(received_path) store_received_file(actual_hash) if actual_hash == filehash FileUtils.cp(received_path.readlink, current_path.to_s) change(Resolved) else received_path.delete return false end end |
#resolve ⇒ Object
222 223 224 225 226 227 228 |
# File 'lib/logical-construct/target/plan-records.rb', line 222 def resolve unless alive? super return false end change(Resolving) end |
#store_received_file(actual_hash) ⇒ Object
189 190 191 192 193 194 195 196 |
# File 'lib/logical-construct/target/plan-records.rb', line 189 def store_received_file(actual_hash) stored_path = storage_path_for(actual_hash) FileUtils.mkdir_p(stored_plans_dir) unless exists?(stored_path) FileUtils.mv(received_path, stored_path) FileUtils.symlink(stored_path, received_path) end end |