photofy 0.2.1 → 0.2.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.
- checksums.yaml +4 -4
- data/lib/photofy/core.rb +6 -6
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 01170cecbe978f73d3a6b5f1c9aad979149a89f2
|
4
|
+
data.tar.gz: dd71457da82f23d3c9121e5ff2c60f86b716309b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 38b61e941bb7cd41fc9bd4df289c3f0d14860b33e45e8004415b8c1374f2d8b75cbceb31c7c0280681ca1df97eb92d243258f871493dfe3f46eb205be0acf31f
|
7
|
+
data.tar.gz: 67ac931b404622c32caf7cde528013d9165f8438b61283157a5b0e2bcb459c6095a2078a0057aa355b48fd11ca2e9c900f6b46df7445e14c287ce13db82437ca
|
data/lib/photofy/core.rb
CHANGED
@@ -64,10 +64,10 @@ module Photofy
|
|
64
64
|
_path = File.join(directory_path, self.send(self.class.primary_key).to_s)
|
65
65
|
_path.gsub!(/^#{Rails.root}\//, "")
|
66
66
|
|
67
|
-
(_s3_objects = s3_bucket.objects.with_prefix("#{_path}_")).count > 0 ? _s3_objects.collect(&:key)[0] :
|
67
|
+
(_s3_objects = s3_bucket.objects.with_prefix("#{_path}_")).count > 0 ? _s3_objects.collect(&:key)[0] : ''
|
68
68
|
else
|
69
69
|
(guessed_file = Dir[File.join(directory_path, "#{self.send(self.class.primary_key).to_s}_*")].first).nil? ?
|
70
|
-
|
70
|
+
'' : guessed_file.to_s
|
71
71
|
end
|
72
72
|
end
|
73
73
|
|
@@ -157,7 +157,7 @@ module Photofy
|
|
157
157
|
#Loading content from parent_photo_field if specified
|
158
158
|
unless parent_photo_field.nil?
|
159
159
|
if s3_connected?
|
160
|
-
unless send("#{parent_photo_field}_path").
|
160
|
+
unless send("#{parent_photo_field}_path").empty?
|
161
161
|
_parent_file_path = send("#{parent_photo_field}_path")
|
162
162
|
_temp_file_path = File.join(Rails.root, File.basename(_parent_file_path))
|
163
163
|
file = File.open(_temp_file_path, 'wb')
|
@@ -169,14 +169,14 @@ module Photofy
|
|
169
169
|
File.delete(file.path)
|
170
170
|
end
|
171
171
|
else
|
172
|
-
send("#{photo_field}=", File.open(send("#{parent_photo_field}_path"))) unless send("#{parent_photo_field}_path").
|
172
|
+
send("#{photo_field}=", File.open(send("#{parent_photo_field}_path"))) unless send("#{parent_photo_field}_path").empty?
|
173
173
|
end
|
174
174
|
end
|
175
175
|
|
176
176
|
unless @photo_file_buffer[photo_field].nil?
|
177
177
|
|
178
178
|
if s3_connected?
|
179
|
-
s3_bucket.objects[send("#{photo_field}_path")].try(:delete) if (not send("#{photo_field}_path").
|
179
|
+
s3_bucket.objects[send("#{photo_field}_path")].try(:delete) if (not send("#{photo_field}_path").empty?) and (s3_bucket.objects.with_prefix(send("#{photo_field}_path")).count > 0)
|
180
180
|
s3_bucket.objects[send("#{photo_field}_path_to_write")].write(@photo_file_buffer[photo_field])
|
181
181
|
|
182
182
|
unless proc.nil?
|
@@ -192,7 +192,7 @@ module Photofy
|
|
192
192
|
file.unlink # deletes the temp file
|
193
193
|
end
|
194
194
|
else
|
195
|
-
File.delete(send("#{photo_field}_path")) if
|
195
|
+
File.delete(send("#{photo_field}_path")) if File.exist?(send("#{photo_field}_path")) #Clearing any existing file at the path
|
196
196
|
File.open(send("#{photo_field}_path_to_write"), "wb+") { |f| f.puts(@photo_file_buffer[photo_field]) }
|
197
197
|
|
198
198
|
unless proc.nil?
|