From d86a8db16281f09d8cfff9ee791297134bce9801 Mon Sep 17 00:00:00 2001 From: Lennart Melzer Date: Mon, 11 May 2020 17:11:53 +0200 Subject: [PATCH] handle restore of multiple asset manifests on rollback (#226) * handle restore of multiple asset manifests on rollback * cosmetic changes * correctly copy sources to targets on asset rollback * Update lib/capistrano/tasks/assets.rake Co-authored-by: Matt Brictson Co-authored-by: Matt Brictson --- lib/capistrano/tasks/assets.rake | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/lib/capistrano/tasks/assets.rake b/lib/capistrano/tasks/assets.rake index f01a62f..ea07399 100644 --- a/lib/capistrano/tasks/assets.rake +++ b/lib/capistrano/tasks/assets.rake @@ -88,10 +88,15 @@ namespace :deploy do task :restore_manifest do on release_roles(fetch(:assets_roles)) do within release_path do - target = detect_manifest_path - source = release_path.join('assets_manifest_backup', File.basename(target)) - if test "[[ -f #{source} && -f #{target} ]]" - execute :cp, source, target + targets = detect_manifest_path.split(' ') + sources = targets.map do |target| + release_path.join('assets_manifest_backup', File.basename(target)) + end + if test(:ls, *sources) && test(:ls, *targets) + source_map = sources.zip(targets) + source_map.each do |source, target| + execute :cp, source, target + end else msg = 'Rails assets manifest file (or backup file) not found.' warn msg