FIX: Don't fail when there's no directory to strip

This commit is contained in:
romanrizzi 2019-10-10 11:21:36 -03:00
parent c5326682d6
commit fa66290b61

View File

@ -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