shrine-transloadit 0.1.1 → 0.1.2

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: 103994ecec1d21c32779635c5a44fa5e9c6bdf87
4
- data.tar.gz: 2d8a3422d5fbc6905240915ddc75ff0bc7315d9f
3
+ metadata.gz: 109ddcc53c8f5fb6ab3ee67461ed619ffec34774
4
+ data.tar.gz: 12379b0d444076bbf9b651d03528e4469f6931d9
5
5
  SHA512:
6
- metadata.gz: a85785e545c36594dedc6897e89615970f017eba1f2364cc9a9de62909e761c2bab4d752c8fbe9574766ed29f7f65886ce6d28d967c098a3059f95f74be05a0f
7
- data.tar.gz: bb0dd002e5156cc62aec52df497655451d5cf3abba75f084a6701a4ac0dfa6f86bec971648c0d904fc481dc923f6cf3447807f68972b86caa03518746edb820f
6
+ metadata.gz: 75aec7f284c57b810adda9ab7c54511958d19310674e15f489cce979f034e76966362baedc2402d3f3873c71f27cb8a8a73ffcc45b5d5dfd2abead88105778a9
7
+ data.tar.gz: 2a338c8f79d6cf7312f15d6880c4d07fdf59f4a21cdc40a2ce653403ea0f7befb82a31b7c275f8e3ac3415ce837cbe0f55b504f5b96325fc7f4de688fda78e23
@@ -36,8 +36,7 @@ class Shrine
36
36
  data = response["fields"]["attacher"]
37
37
  attacher = self.load(data)
38
38
  cached_file = attacher.uploaded_file(data["attachment"])
39
- return if cached_file != attacher.get
40
- attacher.transloadit_save(response)
39
+ attacher.transloadit_save(response, valid: attacher.get == cached_file)
41
40
  attacher
42
41
  end
43
42
 
@@ -62,7 +61,7 @@ class Shrine
62
61
  swap(cached_file)
63
62
  end
64
63
 
65
- def transloadit_save(response)
64
+ def transloadit_save(response, valid: true)
66
65
  if versions = response["fields"]["versions"]
67
66
  stored_file = versions.inject({}) do |hash, (name, key)|
68
67
  result = response["results"].fetch(key)[0]
@@ -74,7 +73,11 @@ class Shrine
74
73
  stored_file = store.transloadit_uploaded_file(result)
75
74
  end
76
75
 
77
- update(stored_file)
76
+ if valid
77
+ update(stored_file)
78
+ else
79
+ _delete(stored_file, phase: :abort)
80
+ end
78
81
  end
79
82
  end
80
83
 
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |gem|
2
2
  gem.name = "shrine-transloadit"
3
- gem.version = "0.1.1"
3
+ gem.version = "0.1.2"
4
4
 
5
5
  gem.required_ruby_version = ">= 2.1"
6
6
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shrine-transloadit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Janko Marohnić