lib/reaver.rb in reaver-0.7.1 vs lib/reaver.rb in reaver-0.10.0
- old
+ new
@@ -3,10 +3,11 @@
require_relative 'reaver/version'
require_relative 'reaver/banner'
require_relative 'reaver/download'
require_relative 'reaver/metadata'
require_relative 'reaver/collection'
+require_relative 'reaver/walk'
require 'whirly'
require 'fileutils'
module Reaver
@@ -20,12 +21,12 @@
WORKDIR = "#{ENV['HOME']}/.config/reaver"
end
# Configure Whirly
Whirly.configure spinner: 'bouncingBar',
- color: true,
- ambiguous_characters_width: 1
+ color: true,
+ ambiguous_characters_width: 1
def self.main
FileUtils.mkdir_p(WORKDIR)
#puts ">> Search collections in #{WORKDIR}"
@@ -38,24 +39,29 @@
FileUtils.mkdir_p(workdir)
collection = Collection.new(f)
collection.load_yaml
- if collection.tasks
- metadata = MetaData.new(workdir, collection)
- metadata.load_yaml
- next_download = metadata.info['next']
+ #puts collection.tasks
- if next_download < Time.new
- #puts ' >> Download time for ' + name
- FileUtils.chdir(workdir)
- #puts " > chdir #{workdir}"
- collection.launch(metadata)
- else
- puts " > Next download > #{next_download}"
- end
+ next unless collection.tasks
- metadata.save_yaml
+ metadata = MetaData.new(workdir, collection)
+ metadata.load_yaml
+ next_download = metadata.info['next']
+ force_download = collection.tasks['force_download'] || false
+ #puts "should we force #{force_download}"
+
+ if next_download < Time.new || force_download
+ #puts ' >> Download time for ' + name
+ FileUtils.chdir(workdir)
+ #puts " > chdir #{workdir}"
+ collection.launch(metadata)
+ collection.save_yaml if force_download
+ else
+ puts " > Next download > #{next_download}"
end
+
+ metadata.save_yaml
end
end
end