s3repo 0.3.2 → 0.3.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a7aebb03a0560b531d8ebfec526dfb222382254a
4
- data.tar.gz: e8904864cd9c3b2f9d6e9947bdcad1f9318727b2
3
+ metadata.gz: a2f5a13bde9581df3d0fddd5322d4395e2eacbbc
4
+ data.tar.gz: 2f3caceae3e9a6b897fbda8ae26ea9ce5e907d89
5
5
  SHA512:
6
- metadata.gz: 17023c621c360ac03fd092dd7a8959c0e506e09c09874ea8856d4873bdb06ebcf99b284288b05cbfc26876f123eb0c103923dcb8cd19ee581d09d74ad71a28e8
7
- data.tar.gz: 327eb69b2a5b7f929043d3470ffbb8fde3f1415dfef2d675e777582bbb89cf08cc49644dbede335dd482e4b7134288a374c4d7029b4cb772464994f61c115b09
6
+ metadata.gz: f82357bd6a0955041133402a4be1b63fda79e67139df33cd0935c797be221981deaca0afb1f8e5d58baaec140c63cab761484cf6651f3964c826ef6de85269c8
7
+ data.tar.gz: fd55dd8cff7c2dc69714dc89bb5113b95945456d2f6636729e074ca0d36e111d2ebb60422628536f615005f1fa7dc1f6efb51875a3309e5ddd875f4d839ef820
data/bin/s3repo CHANGED
@@ -39,6 +39,15 @@ Mercenary.program(:s3repo) do |p|
39
39
  end
40
40
  end
41
41
 
42
+ p.command(:prune) do |c|
43
+ c.syntax 'prune'
44
+ c.description 'Prune package tarballa from the repo'
45
+
46
+ c.action do
47
+ S3Repo.new.prune_packages
48
+ end
49
+ end
50
+
42
51
  p.action do
43
52
  puts p
44
53
  exit 1
@@ -33,6 +33,12 @@ module S3Repo
33
33
  client.upload!('repo.db', db_path)
34
34
  end
35
35
 
36
+ def packages
37
+ return @packages if @packages
38
+ cmd = "tar tf #{db_path}"
39
+ @packages = run(cmd).split.map { |x| x.split('/').first }.uniq
40
+ end
41
+
36
42
  private
37
43
 
38
44
  def sign_db
data/lib/s3repo/repo.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  require 'basiccache'
2
+ require 'set'
2
3
 
3
4
  module S3Repo
4
5
  ##
@@ -17,13 +18,7 @@ module S3Repo
17
18
  end
18
19
 
19
20
  def add_packages(paths)
20
- paths.each do |path|
21
- key = File.basename(path)
22
- sig_key, sig_path = [key, path].map { |x| x + '.sig' }
23
- next if include? key
24
- client.upload!(sig_key, sig_path) if ENV['S3REPO_SIGN_PACKAGES']
25
- client.upload!(key, path)
26
- end
21
+ paths.select! { |path| upload_package(path) }
27
22
  metadata.add_packages(paths)
28
23
  end
29
24
 
@@ -31,6 +26,15 @@ module S3Repo
31
26
  metadata.remove_packages(packages)
32
27
  end
33
28
 
29
+ def prune_packages
30
+ if orphans.empty?
31
+ puts 'No orphaned packages'
32
+ return
33
+ end
34
+ puts "Pruning packages: #{orphans.join(', ')}"
35
+ client.delete_objects(delete: { objects: orphans.map { |x| { key: x } } })
36
+ end
37
+
34
38
  def packages
35
39
  package_cache.cache { parse_packages }
36
40
  end
@@ -46,6 +50,21 @@ module S3Repo
46
50
 
47
51
  private
48
52
 
53
+ def upload_package(path)
54
+ key = File.basename(path)
55
+ sig_key, sig_path = [key, path].map { |x| x + '.sig' }
56
+ return false if include? key
57
+ client.upload!(sig_key, sig_path) if ENV['S3REPO_SIGN_PACKAGES']
58
+ client.upload!(key, path)
59
+ true
60
+ end
61
+
62
+ def orphans
63
+ packages.map(&:key).reject do |x|
64
+ metadata.packages.include? x.reverse.split('-', 2).last.reverse
65
+ end
66
+ end
67
+
49
68
  def metadata
50
69
  @metadata ||= Metadata.new(client: client, file_cache: file_cache)
51
70
  end
@@ -1,5 +1,5 @@
1
1
  ##
2
2
  # Define version
3
3
  module S3Repo
4
- VERSION = '0.3.2'
4
+ VERSION = '0.3.3'
5
5
  end
data/s3repo.gemspec CHANGED
@@ -21,9 +21,9 @@ Gem::Specification.new do |s|
21
21
  s.add_dependency 'aws-sdk', '~> 2.0.0'
22
22
  s.add_dependency 'basiccache', '~> 1.0.0'
23
23
 
24
- s.add_development_dependency 'rubocop', '~> 0.29.0'
24
+ s.add_development_dependency 'rubocop', '~> 0.30.0'
25
25
  s.add_development_dependency 'rake', '~> 10.4.0'
26
- s.add_development_dependency 'coveralls', '~> 0.7.1'
26
+ s.add_development_dependency 'coveralls', '~> 0.8.0'
27
27
  s.add_development_dependency 'rspec', '~> 3.2.0'
28
28
  s.add_development_dependency 'fuubar', '~> 2.0.0'
29
29
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: s3repo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 0.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Les Aker
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-03-16 00:00:00.000000000 Z
11
+ date: 2015-04-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mercenary
@@ -58,14 +58,14 @@ dependencies:
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: 0.29.0
61
+ version: 0.30.0
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: 0.29.0
68
+ version: 0.30.0
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rake
71
71
  requirement: !ruby/object:Gem::Requirement
@@ -86,14 +86,14 @@ dependencies:
86
86
  requirements:
87
87
  - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: 0.7.1
89
+ version: 0.8.0
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
- version: 0.7.1
96
+ version: 0.8.0
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: rspec
99
99
  requirement: !ruby/object:Gem::Requirement