echo_uploads 0.0.5 → 0.0.6
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/echo_uploads/file.rb +3 -1
- data/lib/echo_uploads/perm_file_saving.rb +8 -2
- 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: 1d98d216e5f8935292fe62e093dec3a81bc9099b
|
4
|
+
data.tar.gz: 4ae8d8d9f0e74121a88b8e4b12a860902259adb2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fbc8a9e235934a44f4ff7cf68f1cabcf61871fd4ee604ff8a67a25f8176341d65d087d4abedbfa49625eaf5ad87b97ac405896cc6e94f862a7187fa5ed21c63c
|
7
|
+
data.tar.gz: cb0240f8cb5372d336b99fb235c43ea599e38f623404880b75f3d88d50acc601334c1d513de6c123ace6acd6b9d85f1608e7ca1817ce4f562543f3adfdf86587
|
data/lib/echo_uploads/file.rb
CHANGED
@@ -80,7 +80,9 @@ module EchoUploads
|
|
80
80
|
end
|
81
81
|
save!
|
82
82
|
|
83
|
-
# Write the file to the filestore.
|
83
|
+
# Write the file to the filestore. It's possible that #file is an instance of
|
84
|
+
# EchoUploads::MappedFile, which is a subclass of
|
85
|
+
# ActionDispatch::Http::UploadedFile.
|
84
86
|
if file.is_a?(ActionDispatch::Http::UploadedFile)
|
85
87
|
storage.write key, file.tempfile
|
86
88
|
else
|
@@ -8,8 +8,14 @@ module EchoUploads
|
|
8
8
|
def configure_perm_file_saving(attr, options)
|
9
9
|
# Save the file and the metadata after this model saves.
|
10
10
|
after_save do |model|
|
11
|
-
|
12
|
-
|
11
|
+
@echo_uploads_perm_files_saved ||= {}
|
12
|
+
if (file = send(attr)).present? and @echo_uploads_perm_files_saved[attr.to_sym] != file
|
13
|
+
# A file is being uploaded during this request cycle. Further, we have not
|
14
|
+
# already done the permanent file saving during this request cycle. (It's
|
15
|
+
# not uncommon for a model to be saved twice in one request. If we ran this
|
16
|
+
# code twice, we'd have duplicate effort at best and exceptions at worst.)
|
17
|
+
|
18
|
+
@echo_uploads_perm_files_saved[attr.to_sym] = file
|
13
19
|
|
14
20
|
if options[:multiple]
|
15
21
|
metas = send("#{attr}_metadatas")
|