lib/s3repo/metadata.rb in s3repo-1.0.0 vs lib/s3repo/metadata.rb in s3repo-2.0.0

- old
+ new

@@ -3,15 +3,10 @@ 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}") @@ -27,40 +22,33 @@ end update! end def update! - sign_db if ENV['S3REPO_SIGN_DB'] - client.upload!('repo.db', db_path) + sign_db if @options[:sign_db] + client.upload_file('repo.db', db_path) + client.upload_file('repo.db.tar.xz', db_path) end def packages return @packages if @packages - cmd = "tar tf #{db_path}" + cmd = "bsdtar tf #{db_path}" @packages = run(cmd).split.map { |x| x.split('/').first }.uniq end private - def sign_db - run "gpg --detach-sign --use-agent #{db_path}" - client.upload!('repo.db.sig', "#{db_path}.sig") + def signer + @options[:signer] ||= Signer.new(@options) end - def db_path - @db_path ||= download_db + def sign_db + sig_path = signer.sign(db_path) + client.upload_file('repo.db.sig', sig_path) + client.upload_file('repo.db.tar.xz.sig', sig_path) 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 - ) + def db_path + @db_path ||= file_cache.download('repo.db.tar.xz') end end end