Don't move packaged doc file before decompressing

Ref #457.
pull/417/merge
Thibaut Courouble 9 years ago
parent 8217030453
commit 9c0a7290e6

@ -228,25 +228,18 @@ class DocsCLI < Thor
end end
def download_doc(doc) def download_doc(doc)
target = File.join(Docs.store_path, "#{doc.path}.tar.gz") target_path = File.join(Docs.store_path, doc.path)
open "http://dl.devdocs.io/#{doc.path}.tar.gz" do |file| open "http://dl.devdocs.io/#{doc.path}.tar.gz" do |file|
FileUtils.mkpath(Docs.store_path) FileUtils.mkpath(target_path)
FileUtils.mv(file, target) file.close
unpackage_doc(doc) tar = UnixUtils.gunzip(file.path)
dir = UnixUtils.untar(tar)
FileUtils.rm_rf(target_path)
FileUtils.mv(dir, target_path)
FileUtils.rm(file.path)
end end
end end
def unpackage_doc(doc)
path = File.join(Docs.store_path, doc.path)
FileUtils.mkpath(path)
tar = UnixUtils.gunzip("#{path}.tar.gz")
dir = UnixUtils.untar(tar)
FileUtils.rm_rf(path)
FileUtils.mv(dir, path)
FileUtils.rm(tar)
FileUtils.rm("#{path}.tar.gz")
end
def package_doc(doc) def package_doc(doc)
path = File.join Docs.store_path, doc.path path = File.join Docs.store_path, doc.path

Loading…
Cancel
Save