class ODisk::SyncStarter
Initiates the synchronization of a directory.
Public Class Methods
new(options={})
click to toggle source
Calls superclass method
# File lib/odisk/syncstarter.rb, line 6 def initialize(options={}) @digester = nil @fetcher = nil super(options) @dir_queue.ask(:ready, self) end
Public Instance Methods
set_options(options)
click to toggle source
Calls superclass method
# File lib/odisk/syncstarter.rb, line 13 def set_options(options) super(options) @dir_queue = options[:dir_queue] @digester = options[:digester] @fetcher = options[:fetcher] @collector = options[:collector] end
Private Instance Methods
start(path)
click to toggle source
# File lib/odisk/syncstarter.rb, line 23 def start(path) ::Opee::Env.info("start sync for #{path}") job = DirSyncJob.new(path) @fetcher.ask(:fetch, job) unless @fetcher.nil? @digester.ask(:create, job) unless @digester.nil? top = (path.nil? || path.empty?) ? $local_top : ::File.join($local_top, path) prev_path = ::File.join(top, '.odisk', 'digest.json') job.previous_digest = ::Oj.load_file(prev_path, mode: :object) if ::File.file?(prev_path) @collector.ask(:collect, job, :starter) unless @collector.nil? # ready for another @dir_queue.ask(:ready, self) end