Permalink
Browse files

turn off Ruby's built-in zipfile handling, it's fatally flawed

  • Loading branch information...
1 parent 5f72400 commit 6566011e0c12883ad5df313e130afa8f72f8d2db @bronson bronson committed Sep 10, 2010
Showing with 19 additions and 8 deletions.
  1. +19 −8 scraper
View
@@ -226,7 +226,7 @@ def cached_open(url)
if $ignore_cache || !File.exist?(path) || File.size(path) <= 0
File.open(path, 'w') do |f|
retryable(:tries => 4, :on => [OpenURI::HTTPError, Timeout::Error], :sleep => 10) do |retries|
- puts " downloading #{url}#{retries > 0 ? " TRY #{retries}" : ""}"
+ puts "downloading #{url}#{retries > 0 ? " TRY #{retries}" : ""}"
open(url) { |u| f.write(u.read) }
end
end
@@ -453,7 +453,7 @@ end
def download_file(url, dest)
retryable(:tries => 4, :on => [OpenURI::HTTPError, Timeout::Error], :sleep => 10) do |retries|
- puts "downloading #{url} to #{dest}#{retries > 0 ? " TRY #{retries}" : ""}"
+ puts " downloading #{url} to #{dest}#{retries > 0 ? " TRY #{retries}" : ""}"
open(url, 'rb') do |u|
File.open(dest, 'wb') { |f| f.write(u.read) }
end
@@ -709,11 +709,7 @@ def sense_file(repo, actual_name, pkgfile)
end
-def add_version(repo, version, script)
- # adds all the files in the package to the repo
- pkgfile = download_package(version, script)
- actual_name = sense_file(repo, version['filename'], pkgfile)
-
+def handle_zipfile(repo, script, pkgfile)
tough_zipfiles = [
# ruby's built-in unzipper can't handle these perfectly valid zipfiles:
'packages/2441 - pyflakes.vim/2009-12-29 1.57 pyflakes-vim.zip',
@@ -723,10 +719,25 @@ def add_version(repo, version, script)
# http://www.ruby-forum.com/topic/211146#936159
]
+ # oh FORGET IT, we need to shell out for every zip.
+ # Ruby's built-in unzipper appears to be fatally flawed. :(
+ if true || tough_zipfiles.include?(pkgfile) || script['script_id'].to_i > 3110
+ unshell(repo, script, pkgfile, ['/usr/bin/unzip'])
+ else
+ copy_zipfile(repo, script, pkgfile)
+ end
+end
+
+
+def add_version(repo, version, script)
+ # adds all the files in the package to the repo
+ pkgfile = download_package(version, script)
+ actual_name = sense_file(repo, version['filename'], pkgfile)
+
case actual_name
when nil then # do nothing
when /#{$textext}/ then smart_copy_file(repo, script, actual_name, File.read(pkgfile))
- when /\.zip$/i then tough_zipfiles.include?(pkgfile) || script['script_id'].to_i > 3110 ? unshell(repo, script, pkgfile, ['/usr/bin/unzip']) : copy_zipfile(repo, script, pkgfile)
+ when /\.zip$/i then handle_zipfile(repo, script, pkgfile)
when /\.tar$/ then File.open(pkgfile, 'r') { |file| copy_tarfile(repo, script, file) }
when /\.t?gz$/i then ungzip(pkgfile) { |contents| sense_zipped_file(repo, script, version['filename'].sub(/\.t?gz$/, ''), contents) }
when /\.t?bz2?$/i then unbzip2(pkgfile) { |contents| sense_zipped_file(repo, script, version['filename'].sub(/\.t?bz2?$/, ''), contents) }

0 comments on commit 6566011

Please sign in to comment.