Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds check for whether directory is actually a bundle before moving children out #85

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion lib/cocoapods-downloader/remote_file.rb
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ def extract_with_type(full_filename, type = :zip)
contents = target_path.children
contents.delete(target_path + @filename)
entry = contents.first
if contents.count == 1 && entry.directory?
if contents.count == 1 && entry.directory? && !isBundle?(entry)
tmp_entry = entry.sub_ext("#{entry.extname}.tmp")
begin
FileUtils.move(entry, tmp_entry)
Expand Down Expand Up @@ -173,6 +173,20 @@ def verify_checksum(filename)
verify_sha1_hash(filename, options[:sha1])
end
end

# @note The entry is a bundle if it is a directory but has a bundle structure
#
# @return [Bool] Whether the entry is a bundle
#

def isBundle?(entry)
Copy link
Member

Choose a reason for hiding this comment

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

nit: rename to is_bundle? and remove the extra empty line above the function declaration

Copy link
Author

Choose a reason for hiding this comment

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

I can rename the method and remove the line, but I don't know how to write unit tests in ruby.

As for the CHANGELOG entry, I also wasn't sure of the proper git flow for Cocoapods, so I made the PR into master. Should I then put the entry under Master > Bug Fixes?

isBundle = File.extname(entry) == '.framework'
isBundle ||= File.extname(entry) == '.app'
isBundle ||= File.extname(entry) == '.framework'
Copy link
Contributor

Choose a reason for hiding this comment

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

is this duplicated?

Copy link
Contributor

Choose a reason for hiding this comment

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

what about resource.bundles?

Copy link
Author

@3sands 3sands Jan 18, 2019

Choose a reason for hiding this comment

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

Correct, I accidentally duplicated the line. Will correct and commit change. As for the resource.bundles, should cocoapods check just for the .bundles that way it doesn't miss out on non-resource ones?

Copy link
Member

Choose a reason for hiding this comment

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

yep any .bundle should be caught by this

isBundle ||= File.extname(entry) == '.ipa'
isBundle ||= File.extname(entry) == '.xcappdata'
isBundle
end
end
end
end