match/lib/match/storage/s3_storage.rb in fastlane-2.145.0 vs match/lib/match/storage/s3_storage.rb in fastlane-2.146.0
- old
+ new
@@ -87,11 +87,11 @@
# No existing working directory, creating a new one now
self.working_directory = Dir.mktmpdir
s3_client.find_bucket!(s3_bucket).objects.each do |object|
- file_path = object.public_url.to_s.split("s3.amazonaws.com/").last
+ file_path = object.key # :team_id/path/to/file
download_path = File.join(self.working_directory, file_path)
FileUtils.mkdir_p(File.expand_path("..", download_path))
UI.verbose("Downloading file from S3 '#{file_path}' on bucket #{self.s3_bucket}")
@@ -109,30 +109,31 @@
def upload_files(files_to_upload: [], custom_message: nil)
# `files_to_upload` is an array of files that need to be uploaded to S3
# Those doesn't mean they're new, it might just be they're changed
# Either way, we'll upload them using the same technique
- files_to_upload.each do |current_file|
+ files_to_upload.each do |file_name|
# Go from
# "/var/folders/px/bz2kts9n69g8crgv4jpjh6b40000gn/T/d20181026-96528-1av4gge/profiles/development/Development_me.mobileprovision"
# to
# "profiles/development/Development_me.mobileprovision"
#
- target_path = current_file.gsub(self.working_directory + "/", "")
+ target_path = sanitize_file_name(file_name)
UI.verbose("Uploading '#{target_path}' to S3 Storage...")
- body = File.read(current_file)
+ body = File.read(file_name)
acl = 'private'
s3_url = s3_client.upload_file(s3_bucket, target_path, body, acl)
UI.verbose("Uploaded '#{s3_url}' to S3 Storage.")
end
end
def delete_files(files_to_delete: [], custom_message: nil)
files_to_delete.each do |file_name|
- s3_client.delete_file(s3_bucket, file_name)
+ target_path = sanitize_file_name(file_name)
+ s3_client.delete_file(s3_bucket, target_path)
end
end
def skip_docs
false
@@ -144,9 +145,13 @@
def generate_matchfile_content(template: nil)
return "s3_bucket(\"#{self.s3_bucket}\")"
end
private
+
+ def sanitize_file_name(file_name)
+ file_name.gsub(self.working_directory + "/", "")
+ end
def currently_used_team_id
if self.readonly
# In readonly mode, we still want to see if the user provided a team_id
# see `prefixed_working_directory` comments for more details