Skip to content

Commit

Permalink
Fix bug when a file_clash arise
Browse files Browse the repository at this point in the history
In some cases creating a file would raise an exception, due to clashes
with existing file. E.g. creating a file where a directory with the same
name is present.

This fix rescue the exception and print a "file_clash" warning.
  • Loading branch information
Andrea Nodari committed Mar 18, 2017
1 parent 71f6f54 commit c766fc9
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion lib/thor/actions/empty_directory.rb
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,18 @@ def invoke_with_conflict_check(&block)
if exists?
on_conflict_behavior(&block)
else
say_status :create, :green
yield unless pretend?
say_status :create, :green
end

destination
rescue SystemCallError => e
raise e unless %w(Errno::EISDIR Errno::EEXIST).include?(e.class.name)
on_file_clash_behavior
end

def on_file_clash_behavior
say_status :file_clash, :red
end

# What to do when the destination file already exists.
Expand Down

0 comments on commit c766fc9

Please sign in to comment.