Permalink
Browse files

handle also ftp protocol, remove not copied files

  • Loading branch information...
1 parent a836003 commit f3a93728f291122efc5501c3e4058b25e3fe09e8 @goldmann goldmann committed May 26, 2010
Showing with 11 additions and 6 deletions.
  1. +11 −6 lib/cantiere/rpm.rb
View
@@ -115,7 +115,7 @@ def handle_source(rpm_file, source, version, release)
@log.debug "Handling source '#{source}'..."
- if ( source =~ %r{http://} )
+ if ( source =~ %r{http://} or source =~ %r{ftp://} )
handle_remote_source( rpm_file, source )
else
handle_local_source( rpm_file, source )
@@ -144,12 +144,17 @@ def handle_remote_source(rpm_file, source)
file rpm_file => [ source_file ]
- if ( ! File.exist?( source_cache_file ) )
- FileUtils.mkdir_p( @config.dir.src_cache )
- @exec_helper.execute( "wget #{source} -O #{source_cache_file}" )
- end
+ begin
+ if ( ! File.exist?( source_cache_file ) )
+ FileUtils.mkdir_p( @config.dir.src_cache )
+ @exec_helper.execute( "wget #{source} -O #{source_cache_file}" )
+ end
- FileUtils.cp( source_cache_file, source_file )
+ FileUtils.cp( source_cache_file, source_file )
+ rescue
+ FileUtils.rm_rf( source_cache_file )
+ FileUtils.rm_rf( source_file )
+ end
raise "Source '#{source}' not handled!" unless File.exists?( source_file )
end

0 comments on commit f3a9372

Please sign in to comment.