Module: Fargo::Supports::LocalFileList

Extended by:
ActiveSupport::Concern
Includes:
TTH
Included in:
Client
Defined in:
lib/fargo/supports/local_file_list.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#local_file_listObject (readonly)

Returns the value of attribute local_file_list.



11
12
13
# File 'lib/fargo/supports/local_file_list.rb', line 11

def local_file_list
  @local_file_list
end

#shared_directoriesObject (readonly)

Returns the value of attribute shared_directories.



11
12
13
# File 'lib/fargo/supports/local_file_list.rb', line 11

def shared_directories
  @shared_directories
end

Instance Method Details

#listing_for(query) ⇒ Object



45
46
47
48
49
50
51
52
# File 'lib/fargo/supports/local_file_list.rb', line 45

def listing_for query
  if query =~ /^TTH\/(\w+)$/
    tth = $1
    local_listings.detect{ |l| l.tth = tth }
  else
    local_listings.detect{ |l| l.name == query }
  end
end

#local_file_list_pathObject



33
34
35
# File 'lib/fargo/supports/local_file_list.rb', line 33

def local_file_list_path
  File.join config.config_dir, 'files.xml.bz2'
end

#local_listingsObject



37
38
39
# File 'lib/fargo/supports/local_file_list.rb', line 37

def local_listings
  collect_local_listings local_file_list, [], nil
end

#search_local_listings(search) ⇒ Object



41
42
43
# File 'lib/fargo/supports/local_file_list.rb', line 41

def search_local_listings search
  collect_local_listings local_file_list, [], search
end

#share_directory(dir) ⇒ Object



18
19
20
21
22
23
24
25
26
27
# File 'lib/fargo/supports/local_file_list.rb', line 18

def share_directory dir
  shared_directories << dir unless shared_directories.include? dir

  EventMachine.schedule { # Make sure we run in the reactor
    EventMachine.defer {  # This takes awhile so don't block the reactor
      update_tth dir
      write_file_list
    }
  }
end

#share_sizeObject



29
30
31
# File 'lib/fargo/supports/local_file_list.rb', line 29

def share_size
  config.override_share_size || @share_size
end