Sha256: dd6b79ea048496e7e4dadf5d4eb7a010fc92f9b4632bbadc4eebcb2a57d6ab10

Contents?: true

Size: 1.07 KB

Versions: 15

Compression:

Stored size: 1.07 KB

Contents

module Katello
  class FileUnit < Katello::Model
    include Concerns::PulpDatabaseUnit

    self.table_name = 'katello_files'

    CONTENT_TYPE = Pulp::FileUnit::CONTENT_TYPE

    has_many :repository_files, :class_name => "Katello::RepositoryFile", :dependent => :destroy, :inverse_of => :file, :foreign_key => :file_id
    has_many :repositories, :through => :repository_files, :class_name => "Katello::Repository"

    scoped_search :on => :name, :complete_value => true
    scoped_search :on => :path, :complete_value => true
    scoped_search :on => :checksum

    def self.default_sort
      order(:name)
    end

    def self.repository_association_class
      RepositoryFile
    end

    def self.unit_id_field
      'file_id'
    end

    def update_from_json(json)
      custom_json = {}
      custom_json['checksum'] = json['checksum']
      custom_json['path'] = json['name']
      custom_json['name'] = File.basename(json['name'])
      self.update_attributes!(custom_json)
    end

    def self.total_for_repositories(repos)
      self.in_repositories(repos).count
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
katello-3.11.2 app/models/katello/file_unit.rb
katello-3.10.2 app/models/katello/file_unit.rb
katello-3.10.1.1 app/models/katello/file_unit.rb
katello-3.10.1 app/models/katello/file_unit.rb
katello-3.11.1 app/models/katello/file_unit.rb
katello-3.11.0 app/models/katello/file_unit.rb
katello-3.11.0.rc2 app/models/katello/file_unit.rb
katello-3.11.0.rc1 app/models/katello/file_unit.rb
katello-3.10.0 app/models/katello/file_unit.rb
katello-3.10.0.rc1.1 app/models/katello/file_unit.rb
katello-3.9.1 app/models/katello/file_unit.rb
katello-3.10.0.rc1 app/models/katello/file_unit.rb
katello-3.9.0 app/models/katello/file_unit.rb
katello-3.9.0.rc2 app/models/katello/file_unit.rb
katello-3.9.0.rc1 app/models/katello/file_unit.rb