From: YS <ys...@us...> - 2004-09-27 18:01:41
|
Update of /cvsroot/ngetsuite/ngetsuite/ngetsuite In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3850/ngetsuite Modified Files: downloader.rb downloadmanager.rb queue_file.rb Log Message: - download in subdir is handled by nget with temp files in a temp/ subdir - orphan files link works - cosmetics on search.rthml - ... Index: queue_file.rb =================================================================== RCS file: /cvsroot/ngetsuite/ngetsuite/ngetsuite/queue_file.rb,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** queue_file.rb 25 Feb 2004 22:37:17 -0000 1.17 --- queue_file.rb 27 Sep 2004 18:01:25 -0000 1.18 *************** *** 75,82 **** end ! def finish_err finish('ERROR_RETRIEVING') end def to_s "-- #{@_filename} : [#{@part}/#{@dlparts}], speed = #{@_avgspeed}" --- 75,86 ---- end ! def finish_err_dl finish('ERROR_RETRIEVING') end + def finish_err + finish('ERROR_UNKNOWN') + end + def to_s "-- #{@_filename} : [#{@part}/#{@dlparts}], speed = #{@_avgspeed}" Index: downloadmanager.rb =================================================================== RCS file: /cvsroot/ngetsuite/ngetsuite/ngetsuite/downloadmanager.rb,v retrieving revision 1.26 retrieving revision 1.27 diff -C2 -d -r1.26 -r1.27 *** downloadmanager.rb 27 Sep 2004 13:04:05 -0000 1.26 --- downloadmanager.rb 27 Sep 2004 18:01:25 -0000 1.27 *************** *** 67,73 **** @current_dlers += 1 queueindex, groupindex, type, value, subdir, prio = row.values_at(0, 1, 2, 3, 4, 5) ! group = Group.getname(groupindex) ! log "found /#{value}/ for group #{group}\n" ! dler = Downloader.new(queueindex, type, value, group, @basedir + File::Separator + subdir, prio) @dlers[queueindex] = dler dler.start --- 67,74 ---- @current_dlers += 1 queueindex, groupindex, type, value, subdir, prio = row.values_at(0, 1, 2, 3, 4, 5) ! group = Group.getgroup(groupindex) ! basedir = @basedir ! basedir += File::Separator + group._directory if group._directory ! dler = Downloader.new(queueindex, type, value, group, basedir, subdir, prio) @dlers[queueindex] = dler dler.start Index: downloader.rb =================================================================== RCS file: /cvsroot/ngetsuite/ngetsuite/ngetsuite/downloader.rb,v retrieving revision 1.40 retrieving revision 1.41 diff -C2 -d -r1.40 -r1.41 *** downloader.rb 27 Sep 2004 14:59:40 -0000 1.40 --- downloader.rb 27 Sep 2004 18:01:25 -0000 1.41 *************** *** 21,26 **** # the group attr_reader :group ! # the directory of destination ! attr_reader :dest # the priority attr_reader :prio --- 21,28 ---- # the group attr_reader :group ! # base destination directory (group-wise) ! attr_reader :basedir ! # subdirectory for this download ! attr_reader :subdir # the priority attr_reader :prio *************** *** 30,39 **** attr_reader :nbfiles ! def initialize(queueindex, type, value, group, dest, prio) @queueindex = queueindex @type = type @value = value @group = group ! @dest = dest @prio = prio @status = 'PENDING' --- 32,42 ---- attr_reader :nbfiles ! def initialize(queueindex, type, value, group, basedir, subdir, prio) @queueindex = queueindex @type = type @value = value @group = group ! @basedir = basedir ! @subdir = subdir @prio = prio @status = 'PENDING' *************** *** 50,54 **** case line when /^(\d+) \((\d+)\/(\d+)\): (\d+)\/(\d+)L (\d+)\/(\d+)B\s+(\d+)% (\d+)B\/s (\w+) (\d+)\/(\d+) (\w+)$/ ! part, size, speed, filenb = $2, $7, $9, $12 ldebug "#{green $5+'L'}(#{green $7+'B'}) at #{$9+'B/s'} [#{blue $2}/#{blue $3}] [#{yellow $11}/#{yellow $12}]", false @curfile.update(part, speed, filenb, size) if @curfile --- 53,57 ---- case line when /^(\d+) \((\d+)\/(\d+)\): (\d+)\/(\d+)L (\d+)\/(\d+)B\s+(\d+)% (\d+)B\/s (\w+) (\d+)\/(\d+) (\w+)$/ ! part, size, speed, filenb = $2, $7, $9, $11 ldebug "#{green $5+'L'}(#{green $7+'B'}) at #{$9+'B/s'} [#{blue $2}/#{blue $3}] [#{yellow $11}/#{yellow $12}]", false @curfile.update(part, speed, filenb, size) if @curfile *************** *** 116,120 **** when 'download error occured, keeping temp files.' ldebug "#{yellow 'Error'} while downloading" ! @curfile.finish_err if @curfile @finish_status = 'FAILED' # we do not know the file name --- 119,123 ---- when 'download error occured, keeping temp files.' ldebug "#{yellow 'Error'} while downloading" ! @curfile.finish_err_dl if @curfile @finish_status = 'FAILED' # we do not know the file name *************** *** 175,180 **** def start ! File.makedirs(@dest) ! Dir.chdir(@dest) # unused @start_time = Time.new --- 178,183 ---- def start ! File.makedirs(@basedir) ! Dir.chdir(@basedir) # unused @start_time = Time.new *************** *** 183,187 **** Db.dbh.do "update queue set `status`='PROCESSING', `date_started`=NOW() where `queueindex`='#{@queueindex}'" # Db.dbh.do 'unlock tables' ! ignoreme = (Db.dbh.select_one "select `ignoreregex` from `groups` where `groupindex`='#{Group.getindex(@group)}'")[0] if ignoreme and ignoreme.length > 0 downloadexpr = "-R 'subject #{@value} == subject #{ignoreme} != &&'" --- 186,190 ---- Db.dbh.do "update queue set `status`='PROCESSING', `date_started`=NOW() where `queueindex`='#{@queueindex}'" # Db.dbh.do 'unlock tables' ! ignoreme = (Db.dbh.select_one "select `ignoreregex` from `groups` where `groupindex`='#{@group._groupindex}'")[0] if ignoreme and ignoreme.length > 0 downloadexpr = "-R 'subject #{@value} == subject #{ignoreme} != &&'" *************** *** 189,193 **** downloadexpr = "-r '#{@value}'" end ! @io = IO.popen("#{"nice -n#{$config['nice_nget_download']} -- " if $config['nice_nget_download'] != 0} #{$config['nget']} -q -G #{@group} #{downloadexpr} 2>&1") @t = Thread.new(@io, self){ |io, parent| begin --- 192,199 ---- downloadexpr = "-r '#{@value}'" end ! ! subdirexpr = "-p ." + File::Separator + "'#{@subdir}' -P ." + File::Separator + "'#{@subdir}'" + File::Separator + "temp" ! ! @io = IO.popen("#{"nice -n#{$config['nice_nget_download']} -- " if $config['nice_nget_download'] != 0} #{$config['nget']} -q -dfI --makedirs yes #{subdirexpr} -G #{@group._fullname} #{downloadexpr} 2>&1") @t = Thread.new(@io, self){ |io, parent| begin *************** *** 210,214 **** } ldebug 'Downloader started for ' + green(@value) ! log "Download started for #{@value}, group #{@group} to #{@dest}" end --- 216,220 ---- } ldebug 'Downloader started for ' + green(@value) ! log "Download started for #{@value}, group #{@group._fullname} to #{@subdir}" end *************** *** 231,236 **** @t.exit ! ldebug "Download stopped for #{green @value}, group #{@group}" ! log "Download stopped for #{@value}, group #{@group}" end --- 237,242 ---- @t.exit ! ldebug "Download stopped for #{green @value}, group #{@group._fullname}" ! log "Download stopped for #{@value}, group #{@group._fullname}" end *************** *** 248,252 **** Db.dbh.do 'unlock tables' ldebug "Download #{newstatus.downcase} for #{green @value}" ! log "Download #{newstatus.downcase} for #{@value}, group #{@group}" end --- 254,258 ---- Db.dbh.do 'unlock tables' ldebug "Download #{newstatus.downcase} for #{green @value}" ! log "Download #{newstatus.downcase} for #{@value}, group #{@group._fullname}" end |