echo_uploads 0.0.5 → 0.0.6

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: 7d5f3c3877293549591cb0b210da8b75841d3efb
4
- data.tar.gz: 8715dbd533d79b3aa94b36bab80084d025510b92
3
+ metadata.gz: 1d98d216e5f8935292fe62e093dec3a81bc9099b
4
+ data.tar.gz: 4ae8d8d9f0e74121a88b8e4b12a860902259adb2
5
5
  SHA512:
6
- metadata.gz: ad94175bf8c3bb5a456953dbca2823a11d4b764a85ef765adfb4ba0681aa50495b7c0b45972d5774c0737dce5a8fcb405ad7fbc23d420f1c1c8959375e2c5014
7
- data.tar.gz: fd37684f880e8ad4e8a9534054cb4a7a3a4719cdd5ecff0852d4a901b2fecb1ecee8d661a0edcaf1ea55b62c33ce1708399e0819a7080da8df1b9ea65595af02
6
+ metadata.gz: fbc8a9e235934a44f4ff7cf68f1cabcf61871fd4ee604ff8a67a25f8176341d65d087d4abedbfa49625eaf5ad87b97ac405896cc6e94f862a7187fa5ed21c63c
7
+ data.tar.gz: cb0240f8cb5372d336b99fb235c43ea599e38f623404880b75f3d88d50acc601334c1d513de6c123ace6acd6b9d85f1608e7ca1817ce4f562543f3adfdf86587
@@ -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
- if (file = send(attr)).present?
12
- # A file is being uploaded during this request cycle.
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")
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: echo_uploads
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jarrett Colby