Slightly more robust extension downloader.
This commit is contained in:
parent
cb9672bd9e
commit
d4971fcfaa
@ -20,12 +20,14 @@ end
|
|||||||
|
|
||||||
|
|
||||||
if !File.exists?(extdir)
|
if !File.exists?(extdir)
|
||||||
puts "Downloading and unpacking the ninesixty plugin."
|
begin
|
||||||
|
puts "Downloading the ninesixty plugin."
|
||||||
FileUtils.mkdir(extdir)
|
FileUtils.mkdir(extdir)
|
||||||
zipfile = File.join(extdir, "ninesixty.zip")
|
zipfile = File.join(extdir, "ninesixty.zip")
|
||||||
open(zipfile, "wb") do |tgz|
|
open(zipfile, "wb") do |tgz|
|
||||||
tgz << fetch(download_link).body
|
tgz << fetch(download_link).body
|
||||||
end
|
end
|
||||||
|
puts "Unzipping the ninesixty plugin."
|
||||||
Zip::ZipFile::open(zipfile) { |zf|
|
Zip::ZipFile::open(zipfile) { |zf|
|
||||||
zf.each { |e|
|
zf.each { |e|
|
||||||
fpath = File.join(extdir, e.name)
|
fpath = File.join(extdir, e.name)
|
||||||
@ -36,4 +38,8 @@ if !File.exists?(extdir)
|
|||||||
File.unlink(zipfile)
|
File.unlink(zipfile)
|
||||||
funky_directory = Dir.glob(File.join(extdir,'chriseppstein-compass-960-plugin-*'))[0]
|
funky_directory = Dir.glob(File.join(extdir,'chriseppstein-compass-960-plugin-*'))[0]
|
||||||
FileUtils.mv(funky_directory, File.join(extdir,'ninesixty'))
|
FileUtils.mv(funky_directory, File.join(extdir,'ninesixty'))
|
||||||
|
rescue Exception => e
|
||||||
|
FileUtils.rmdir(extdir)
|
||||||
|
raise
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user