effective_storage 0.3.2 → 0.4.0

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
  SHA256:
3
- metadata.gz: e4d882d7dc41b30bee6a440cffcbcc0008dc697fc5ace3455ff2f427910325d1
4
- data.tar.gz: a6a536963a71e23feeb0106193a7d731372f3190cf48632aa5cb70388636df31
3
+ metadata.gz: d31c97986b5166e4bd1fa34d329ea5a6b8f7c355a9ab952f010100ba8ed33f63
4
+ data.tar.gz: e88cce63f52489de5fed02e3c5119f4ff17cb5ca07fba05472b15d5cfcfdd814
5
5
  SHA512:
6
- metadata.gz: fc59eaafef6892fb1b3826e7ad0ee0f5aacf175f553cdae2eb8bc15a2631a72ea4681f2ef6b7c594f5497007df06f7acfd91c9f76480b4d49e96811b1a637781
7
- data.tar.gz: 12d4c064a19a72670545e52f61c986c80455c90ae4852af9c3e272aea56a4331d7e7e0065e9cdfeff860f25f1e12f282b180815dd1145e1af33e66d7e2c863a4
6
+ metadata.gz: 405aa9bb4a51b937c3c551af74327774078418ed01e96b13340806c0dca6dc6fc1bd9824147d3472f65aec8bdc8db49d9dfe5903215e87ee17f3958aefa3f518
7
+ data.tar.gz: d6058d78e87602fdfbb7639e0e66628c691edd6c22c1823c6697343a8ede5359d09da98c3daa729f146c2e608cc1bf66045cad9785c228d01e1b69ce4b60d55f
@@ -47,8 +47,55 @@ module ActiveStorageBlobExtension
47
47
  save!
48
48
  end
49
49
 
50
+ # The purge! command is not part of the regular ActiveStorage::Blob class
51
+ # This is the command called by the admin/storage datatable
52
+ # When config.never_delete_active_storage is enabled, this is the only way to delete a Blob
53
+ # And they will not be deleted in the background.
50
54
  def purge!
51
- purge
55
+ before = EffectiveStorage.never_delete
56
+
57
+ begin
58
+ EffectiveStorage.never_delete = false
59
+ purge
60
+ ensure
61
+ EffectiveStorage.never_delete = before
62
+ end
63
+ end
64
+
65
+ def delete
66
+ if EffectiveStorage.never_delete?
67
+ Rails.logger.info "[effective_storage] Skipping ActiveStorage::Blob delete"
68
+ return
69
+ end
70
+
71
+ super
72
+ end
73
+
74
+ def destroy
75
+ if EffectiveStorage.never_delete?
76
+ Rails.logger.info "[effective_storage] Skipping ActiveStorage::Blob destroy"
77
+ return
78
+ end
79
+
80
+ super
81
+ end
82
+
83
+ def purge
84
+ if EffectiveStorage.never_delete?
85
+ Rails.logger.info "[effective_storage] Skipping ActiveStorage::Blob purge"
86
+ return
87
+ end
88
+
89
+ super
90
+ end
91
+
92
+ def purge_later
93
+ if EffectiveStorage.never_delete?
94
+ Rails.logger.info "[effective_storage] Skipping ActiveStorage::Blob purge_later"
95
+ return
96
+ end
97
+
98
+ super
52
99
  end
53
100
 
54
101
  end
@@ -6,4 +6,7 @@ EffectiveStorage.setup do |config|
6
6
  # Perform authorization on ActiveStorage downloads
7
7
  # When false any request will be permitted (the default)
8
8
  config.authorize_active_storage = true
9
+
10
+ # Do not delete ActiveStorage::Blobs
11
+ config.never_delete = true
9
12
  end
@@ -1,3 +1,3 @@
1
1
  module EffectiveStorage
2
- VERSION = '0.3.2'.freeze
2
+ VERSION = '0.4.0'.freeze
3
3
  end
@@ -6,7 +6,7 @@ require 'effective_storage/version'
6
6
  module EffectiveStorage
7
7
 
8
8
  def self.config_keys
9
- [:layout, :authorize_active_storage]
9
+ [:layout, :authorize_active_storage, :never_delete]
10
10
  end
11
11
 
12
12
  include EffectiveGem
@@ -15,4 +15,8 @@ module EffectiveStorage
15
15
  authorize_active_storage == true
16
16
  end
17
17
 
18
+ def self.never_delete?
19
+ never_delete == true
20
+ end
21
+
18
22
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: effective_storage
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Code and Effect
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-02-21 00:00:00.000000000 Z
11
+ date: 2023-03-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails