FIX/FEATURE: don't blow up when can't reach theme's repo, show problem themes on dashboard

This commit is contained in:
OsamaSayegh
2018-09-08 16:24:11 +03:00
committed by Sam
parent ca28548762
commit c7d81e2682
14 changed files with 139 additions and 22 deletions

View File

@@ -2,6 +2,7 @@ module ThemeStore; end
class ThemeStore::GitImporter
class ImportFailed < StandardError; end
attr_reader :url
def initialize(url, private_key: nil)
@@ -65,7 +66,11 @@ class ThemeStore::GitImporter
protected
def import_public!
Discourse::Utils.execute_command("git", "clone", @url, @temp_folder)
begin
Discourse::Utils.execute_command("git", "clone", @url, @temp_folder)
rescue => err
raise ImportFailed.new(err.message)
end
end
def import_private!
@@ -77,9 +82,13 @@ class ThemeStore::GitImporter
FileUtils.chmod(0600, 'id_rsa')
end
Discourse::Utils.execute_command({
'GIT_SSH_COMMAND' => "ssh -i #{ssh_folder}/id_rsa -o StrictHostKeyChecking=no"
}, "git", "clone", @url, @temp_folder)
begin
Discourse::Utils.execute_command({
'GIT_SSH_COMMAND' => "ssh -i #{ssh_folder}/id_rsa -o StrictHostKeyChecking=no"
}, "git", "clone", @url, @temp_folder)
rescue => err
raise ImportFailed.new(err.message)
end
ensure
FileUtils.rm_rf ssh_folder
end