Skip to content

Commit

Permalink
FIX: Don't fail when there's no directory to strip
Browse files Browse the repository at this point in the history
  • Loading branch information
romanrizzi committed Oct 10, 2019
1 parent c532668 commit fa66290
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/compression/strategy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,10 @@ def decompress(dest_path, compressed_file_path, allow_non_root_folder: false)
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
Expand Down

1 comment on commit fa66290

@discoursebot
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This commit has been mentioned on Discourse Meta. There might be relevant details there:

https://meta.discourse.org/t/error-while-restoring-backup-on-amazon-ec2-instance/130683/5

Please sign in to comment.