activestorage-horcrux 0.0.1 → 0.0.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/active_storage/service/horcrux_service.rb +25 -11
- data/lib/active_storage/service/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5e3f1b44e9be312f76b1f54bc9aac82d024b8c48110508e746b27e3c524e7636
|
4
|
+
data.tar.gz: cef3c2477017ed6228d4bcdad96a5b647c74695de257582d7723e8105cb502cd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 149fc099063b20a0f14f28dda79ec41b23f0e90bd160fec681908fe12c6afcd50c7273164389b5f9a0fccd8f33a7054a51ab649e92fab92c3cad6355ffecf511
|
7
|
+
data.tar.gz: 6a678681feb0b3de7e6273bc8cdd2ad4769ee681916d8fa49e8796a318c5b6c38b2251c908d4793cca09999e6e5b790cf954620cddfafb416a3955c6fefbbac4
|
@@ -8,7 +8,7 @@ require "active_support/core_ext/module/delegation"
|
|
8
8
|
|
9
9
|
module ActiveStorage
|
10
10
|
class Service::HorcruxService < Service
|
11
|
-
attr_reader :services, :shares, :threshold
|
11
|
+
attr_reader :services, :shares, :threshold, :prefix
|
12
12
|
|
13
13
|
def upload(key,io,checksum: nil, **options)
|
14
14
|
data = io.tap(&:rewind).read
|
@@ -23,7 +23,8 @@ module ActiveStorage
|
|
23
23
|
end
|
24
24
|
svc = servicesamples.sample
|
25
25
|
shardkey = SecureRandom.base58(key.length)
|
26
|
-
|
26
|
+
shardkey = svc[:name] + ':' + shardkey if prefix
|
27
|
+
svc[:service].upload shardkey, StringIO.new(shards[i]), checksum: nil, **options
|
27
28
|
file.write("#{shardkey},")
|
28
29
|
servicesamples.delete(svc)
|
29
30
|
i = i + 1
|
@@ -38,8 +39,8 @@ module ActiveStorage
|
|
38
39
|
while i < shardkeys.count
|
39
40
|
j = 0
|
40
41
|
while j < services.count
|
41
|
-
if services[j].exist?(shardkeys[i])
|
42
|
-
shards << services[j].download(shardkeys[i])
|
42
|
+
if services[j][:service].exist?(shardkeys[i])
|
43
|
+
shards << services[j][:service].download(shardkeys[i])
|
43
44
|
end
|
44
45
|
j = j + 1
|
45
46
|
end
|
@@ -57,20 +58,33 @@ module ActiveStorage
|
|
57
58
|
raise ActiveStorage::UnpreviewableError, "Horcrux does not implement ranged download yet"
|
58
59
|
end
|
59
60
|
|
60
|
-
def delete(
|
61
|
-
|
61
|
+
def delete(keys)
|
62
|
+
shardkeys = keys.split(',')
|
63
|
+
shards = []
|
64
|
+
i = 0
|
65
|
+
while i < shardkeys.count
|
66
|
+
j = 0
|
67
|
+
while j < services.count
|
68
|
+
if services[j][:service].exist?(shardkeys[i])
|
69
|
+
services[j][:service].delete(shardkeys[i])
|
70
|
+
end
|
71
|
+
j = j + 1
|
72
|
+
end
|
73
|
+
i = i + 1
|
74
|
+
end
|
62
75
|
end
|
63
76
|
|
64
77
|
# Stitch together from named services.
|
65
|
-
def self.build(services:, shares:, threshold:, configurator:, **options) #:nodoc:
|
78
|
+
def self.build(services:, shares:, threshold:, prefix:, configurator:, **options) #:nodoc:
|
66
79
|
new \
|
67
80
|
shares: shares,
|
68
81
|
threshold: threshold,
|
69
|
-
|
82
|
+
prefix: prefix,
|
83
|
+
services: services.collect { |name| { :name => name, :service => configurator.build(name) } }
|
70
84
|
end
|
71
85
|
|
72
|
-
def initialize(shares:,threshold:,services:)
|
73
|
-
@shares, @threshold, @services = shares, threshold, services
|
86
|
+
def initialize(shares:,threshold:,prefix:,services:)
|
87
|
+
@shares, @threshold, @prefix, @services = shares, threshold, prefix, services
|
74
88
|
end
|
75
89
|
|
76
90
|
def delete_prefixed(*args)
|
@@ -83,7 +97,7 @@ module ActiveStorage
|
|
83
97
|
while i < localKeys.count
|
84
98
|
j = 0
|
85
99
|
while j < services.count
|
86
|
-
if services[j].exist?(localKeys[i])
|
100
|
+
if services[j][:service].exist?(localKeys[i])
|
87
101
|
return true
|
88
102
|
end
|
89
103
|
j = j + 1
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activestorage-horcrux
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- John Callahan
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-08-
|
11
|
+
date: 2020-08-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|