Sha256: 07c86d7adf8193f8bdd69d7f3bf30df83cf5c21452b3ba91aed77bbac06d40e8

Contents?: true

Size: 832 Bytes

Versions: 7

Compression:

Stored size: 832 Bytes

Contents

require 'fileutils'
require 'tempfile'

module S3Repo
  ##
  # Metadata object, represents repo's DB file
  class Metadata < Base
    def initialize(params = {})
      super
      FileUtils.mkdir_p db_dir
    end

    def add_packages(paths)
      @db_path = nil
      paths.each do |path|
        puts "Adding #{File.basename(path)} to repo.db"
        run("repo-add #{db_path} #{path}")
      end
      client.upload!('repo.db', db_path)
    end

    private

    def db_path
      @db_path ||= download_db
    end

    def download_db
      tmpfile = Tempfile.create(['repo', '.db.tar.xz'], db_dir)
      tmpfile << file_cache.serve('repo.db')
      tmpfile.close
      tmpfile.path
    end

    def db_dir
      @db_dir ||= File.absolute_path(
        @options[:tmpdir] || Cache::TMPDIRS.compact.first
      )
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
s3repo-0.1.7 lib/s3repo/metadata.rb
s3repo-0.1.5 lib/s3repo/metadata.rb
s3repo-0.1.4 lib/s3repo/metadata.rb
s3repo-0.1.3 lib/s3repo/metadata.rb
s3repo-0.1.2 lib/s3repo/metadata.rb
s3repo-0.1.1 lib/s3repo/metadata.rb
s3repo-0.1.0 lib/s3repo/metadata.rb