Skip to content
This repository has been archived by the owner on Nov 19, 2018. It is now read-only.

Commit

Permalink
Fixed pre-downloading screenshots into wrong folder
Browse files Browse the repository at this point in the history
  • Loading branch information
KrauseFx committed Mar 20, 2015
1 parent 91ecb4a commit 779794c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
9 changes: 5 additions & 4 deletions lib/deliver/deliverfile/deliverfile_creator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,16 @@ def self.create_based_on_identifier(deliver_path, identifier, project_name)
app.set_metadata_directory("/tmp") # we don't want to pollute the current folder
app.metadata # this will download the latest app metadata

file_path = [deliver_path, Deliver::Deliverfile::Deliverfile::FILE_NAME].join('/')
file_path = File.join(deliver_path, Deliver::Deliverfile::Deliverfile::FILE_NAME)
json = generate_deliver_file(app, deliver_path, project_name)
File.write(file_path, json)

FileUtils.mkdir_p './screenshots/'
FileUtils.mkdir_p File.join(deliver_path, 'screenshots')
begin
Helper.log.info "Downloading all previously used app screenshots.".green
ItunesConnect.new.download_existing_screenshots(app)
rescue
ItunesConnect.new.download_existing_screenshots(app, deliver_path)
rescue Exception => ex
Helper.log.error ex
Helper.log.error "Couldn't download already existing screenshots from iTunesConnect. You have to add them manually!".red
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@ class ItunesConnect < FastlaneCore::ItunesConnect

# This method will download all existing app screenshots
# @param app (Deliver::App) the app you want this information from
# @param folder_path (String) the path to store the screenshots in
# @raise [ItunesConnectGeneralError] General error while executing
# this action
# @raise [ItunesConnectLoginError] Login data is wrong
def download_existing_screenshots(app)
def download_existing_screenshots(app, folder_path)
languages = JSON.parse(File.read(File.join(Helper.gem_path('deliver'), "lib", "assets", "DeliverLanguageMapping.json")))

begin
Expand Down Expand Up @@ -40,7 +41,7 @@ def download_existing_screenshots(app)
file_name = [screenshot['value']['sortOrder'], type, screenshot['value']['originalFileName']].join("_")
Helper.log.info "Downloading existing screenshot '#{file_name}' of device type: '#{type}'"

containing_folder = File.join(".", "screenshots", language_code)
containing_folder = File.join(folder_path, "screenshots", language_code)
FileUtils.mkdir_p containing_folder rescue nil # if it's already there
path = File.join(containing_folder, file_name)
File.write(path, open(url).read)
Expand Down

0 comments on commit 779794c

Please sign in to comment.