mirror of
https://github.com/discourse/discourse.git
synced 2024-11-25 09:42:07 +08:00
FIX: Don't fail when there's no directory to strip
This commit is contained in:
parent
c5326682d6
commit
fa66290b61
|
@ -33,8 +33,10 @@ module Compression
|
||||||
end
|
end
|
||||||
|
|
||||||
def strip_directory(from, to, relative: false)
|
def strip_directory(from, to, relative: false)
|
||||||
sanitized_from = sanitize_path(from)
|
sanitized_from = sanitize_path(from) rescue nil
|
||||||
sanitized_to = sanitize_path(to)
|
sanitized_to = sanitize_path(to) rescue nil
|
||||||
|
return unless sanitized_from && sanitized_to
|
||||||
|
|
||||||
glob_path = relative ? "#{sanitized_from}/*/*" : "#{sanitized_from}/**"
|
glob_path = relative ? "#{sanitized_from}/*/*" : "#{sanitized_from}/**"
|
||||||
FileUtils.mv(Dir.glob(glob_path), sanitized_to) if File.directory?(sanitized_from)
|
FileUtils.mv(Dir.glob(glob_path), sanitized_to) if File.directory?(sanitized_from)
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue
Block a user