Class: Saber::Task::CHD

Inherits:
Base
  • Object
show all
Defined in:
lib/saber/task/chd.rb

Instance Method Summary collapse

Methods inherited from Base

inherited, #initialize, invoke

Constructor Details

This class inherits a constructor from Saber::Task::Base

Instance Method Details

#chd(o = {}) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/saber/task/chd.rb', line 8

def chd(o={})
  t = Tracker["chd"].new

  begin
    t.
    Saber.ui.say "Begin to watch."
    # mark all loaded.
    t.update_cache(true)

    while true
      # check free diskspace
      s = Sys::Filesystem.stat(Rc.chd.diskspace_dir.p)
      if s.block_size * s.blocks_free < Rc.chd.diskspace_limit
        Saber.ui.say "::SKIP:: Reach low diskspace."
      else
        t.add_torrents
      end

      sleep Rc.chd.update_interval
    end
  rescue Errno::ETIMEDOUT, Mechanize::ResponseCodeError, SocketError
    sleep 60
    retry
  end
end