jammit-s3 0.6.0.1 → 0.6.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/jammit-s3.gemspec +1 -1
- data/lib/jammit/s3_uploader.rb +24 -10
- metadata +4 -4
data/jammit-s3.gemspec
CHANGED
data/lib/jammit/s3_uploader.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'mimemagic'
|
2
|
+
require 'digest/md5'
|
2
3
|
|
3
4
|
module Jammit
|
4
5
|
class S3Uploader
|
@@ -56,17 +57,30 @@ module Jammit
|
|
56
57
|
use_gzip = true
|
57
58
|
remote_path = remote_path.gsub(/\.gz$/, "")
|
58
59
|
end
|
60
|
+
|
61
|
+
# check if the file already exists on s3
|
62
|
+
begin
|
63
|
+
obj = @bucket.objects.find_first(remote_path)
|
64
|
+
rescue
|
65
|
+
obj = nil
|
66
|
+
end
|
59
67
|
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
68
|
+
# if the object does not exist, or if the MD5 Hash / etag of the
|
69
|
+
# file has changed, upload it
|
70
|
+
if !obj || (obj.etag != Digest::MD5.hexdigest(File.read(local_path)))
|
71
|
+
log "pushing file to s3: #{remote_path}"
|
72
|
+
|
73
|
+
# save to s3
|
74
|
+
new_object = @bucket.objects.build(remote_path)
|
75
|
+
new_object.cache_control = @cache_control if @cache_control
|
76
|
+
new_object.content_type = MimeMagic.by_path(remote_path)
|
77
|
+
new_object.content = open(local_path)
|
78
|
+
new_object.content_encoding = "gzip" if use_gzip
|
79
|
+
new_object.acl = @acl if @acl
|
80
|
+
new_object.save
|
81
|
+
else
|
82
|
+
log "file has not changed: #{remote_path}"
|
83
|
+
end
|
70
84
|
end
|
71
85
|
end
|
72
86
|
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: jammit-s3
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.6.0.
|
5
|
+
version: 0.6.0.2
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Jacques Crocker
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-03-
|
13
|
+
date: 2011-03-18 00:00:00 -07:00
|
14
14
|
default_executable:
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
@@ -75,7 +75,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
75
75
|
requirements:
|
76
76
|
- - ">="
|
77
77
|
- !ruby/object:Gem::Version
|
78
|
-
hash:
|
78
|
+
hash: 1181583477013586615
|
79
79
|
segments:
|
80
80
|
- 0
|
81
81
|
version: "0"
|
@@ -84,7 +84,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
84
84
|
requirements:
|
85
85
|
- - ">="
|
86
86
|
- !ruby/object:Gem::Version
|
87
|
-
hash:
|
87
|
+
hash: 1181583477013586615
|
88
88
|
segments:
|
89
89
|
- 0
|
90
90
|
version: "0"
|