From fa66290b61d0e14a5a367c01eb955289ae791068 Mon Sep 17 00:00:00 2001 From: romanrizzi Date: Thu, 10 Oct 2019 11:21:36 -0300 Subject: [PATCH] FIX: Don't fail when there's no directory to strip --- lib/compression/strategy.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/compression/strategy.rb b/lib/compression/strategy.rb index f5cd0ab1b71..921ebd80135 100644 --- a/lib/compression/strategy.rb +++ b/lib/compression/strategy.rb @@ -33,8 +33,10 @@ module Compression end def strip_directory(from, to, relative: false) - sanitized_from = sanitize_path(from) - sanitized_to = sanitize_path(to) + sanitized_from = sanitize_path(from) rescue nil + sanitized_to = sanitize_path(to) rescue nil + return unless sanitized_from && sanitized_to + glob_path = relative ? "#{sanitized_from}/*/*" : "#{sanitized_from}/**" FileUtils.mv(Dir.glob(glob_path), sanitized_to) if File.directory?(sanitized_from) end