@@ -409,7 +409,7 @@ def sync(hosts : Array(String))
409409 spawn do
410410 begin
411411 sync_host(host, hosts_files: hosts_files, common_files: common_files, mirror_to: mirror[host]?)
412- continue_download (host, BACKUP_DIR .join(host), [Path [" var/log/nginx/access.log" ]])
412+ download (host, BACKUP_DIR .join(host), [Path [" var/log/nginx/access.log" ]])
413413 done.send(nil )
414414 rescue e
415415 error(" host=#{ host } sync failure: #{ e } \n " )
@@ -453,21 +453,9 @@ def sync_host(host : String, *, hosts_files : Hash(String, Set(Path)), common_fi
453453 ssh(host, [" sudo etckeeper commit sync 2>>/dev/null" ])
454454end
455455
456- def continue_download (host : String , local_dir : Path , files : Enumerable (Path ))
456+ def download (host : String , local_dir : Path , files : Enumerable (Path ))
457457 Dir .mkdir_p(local_dir)
458- checks = files
459- .map { |i | [i, local_dir.join(i)] }
460- .select { |(i , local_full )| File .file?(local_full) }
461- .map { |(i , local_full )|
462- command = " head -c #{ File .size(local_full)} /#{ i } | sha256sum | cut -d' ' -f 1"
463- expected_checksum = ` sha256sum #{ local_full } | cut -d' ' -f 1` .strip
464- [command, expected_checksum]
465- }
466- checksums = ssh(host, checks.map { |(command , _ )| command }).split('\n' ).reject { |i | i.empty? }
467- raise " unexpected output" unless checks.size == checksums.size
468- failures = checksums.zip(checks.map { |(_ , expected_checksum )| expected_checksum }).reject { |a , b | a == b }
469- raise " some checksums failed: #{ failures } " unless failures.empty?
470- rsync(local_dir, files, [" --append-verify" , " #{ host } :/" , " ." ])
458+ rsync(local_dir, files, [" #{ host } :/" , " ." ])
471459end
472460
473461def add_user_commands (user : String )
0 commit comments