s3_migration 0.1.0 → 0.1.1
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/s3_migration/file_migrator.rb +1 -1
- data/lib/s3_migration/migrate_file_set_job.rb +2 -2
- data/lib/s3_migration/quarantine.rb +1 -1
- data/lib/s3_migration/storage_report.rb +1 -1
- data/lib/s3_migration/upload_cleanup.rb +1 -1
- data/lib/s3_migration/version.rb +1 -1
- data/lib/s3_migration.rb +30 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 3d0c1aad0021835d5ff8465192330a126687faed7599bfbd80b470bc856d3545
|
|
4
|
+
data.tar.gz: 857093deac26f2df2c9deb46c32f42f5cc99fac772bdf892333a2afd170280ca
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 29a5c98a1d1fe1f234f2b7b634825ebebe33e4fc67f874122cd442ee18da4296f4b42c32c39ff41a5194b8062bef7d4e7077ffba3c13d8bd1074574274f7cb62
|
|
7
|
+
data.tar.gz: eb01c4628148b16461a2734edb677b1940f41e1427d34bdbd16657dbd0d1c4d6c21ac5714fc7be20a1eb9f563c917bd86b5aa5f5677ad36204b53986e7960970
|
|
@@ -99,7 +99,7 @@ module S3Migration
|
|
|
99
99
|
end
|
|
100
100
|
|
|
101
101
|
def switch_identifier(uploaded, disk_sha256)
|
|
102
|
-
current =
|
|
102
|
+
current = S3Migration.find_resource(original.id)
|
|
103
103
|
unless SourceStorage.handles?(current.file_identifier)
|
|
104
104
|
return result(:raced, 'already migrated by another process')
|
|
105
105
|
end
|
|
@@ -8,8 +8,8 @@ module S3Migration
|
|
|
8
8
|
retry_on StandardError, wait: :polynomially_longer, attempts: 5
|
|
9
9
|
|
|
10
10
|
def perform(file_set_id, dry_run: false)
|
|
11
|
-
file_set =
|
|
12
|
-
original =
|
|
11
|
+
file_set = S3Migration.find_file_set(file_set_id)
|
|
12
|
+
original = S3Migration.find_original_file(file_set:)
|
|
13
13
|
return unless original
|
|
14
14
|
|
|
15
15
|
result = S3Migration::FileMigrator.new(file_set:, original:, dry_run:).call
|
|
@@ -26,7 +26,7 @@ module S3Migration
|
|
|
26
26
|
|
|
27
27
|
# When the database cannot be read, keep the upload: the manifest entry still points at it.
|
|
28
28
|
def referenced?(upload_id)
|
|
29
|
-
|
|
29
|
+
S3Migration.find_resource(file_metadata_id).file_identifier == upload_id
|
|
30
30
|
rescue StandardError
|
|
31
31
|
true
|
|
32
32
|
end
|
data/lib/s3_migration/version.rb
CHANGED
data/lib/s3_migration.rb
CHANGED
|
@@ -58,12 +58,41 @@ module S3Migration
|
|
|
58
58
|
end
|
|
59
59
|
|
|
60
60
|
def original_for(file_set, on_error: nil)
|
|
61
|
-
|
|
61
|
+
find_original_file(file_set:)
|
|
62
62
|
rescue StandardError => e
|
|
63
63
|
on_error&.call(file_set, e)
|
|
64
64
|
nil
|
|
65
65
|
end
|
|
66
66
|
|
|
67
|
+
# The lookups below ask only the non-Wings services. The composite ones also ask Wings, and a miss there
|
|
68
|
+
# reaches Fedora, which can hang (and ActiveFedora may try to create the tenant's base container).
|
|
69
|
+
def find_resource(id)
|
|
70
|
+
each_service_result { |service| service.find_by(id:) }.first || raise(Valkyrie::Persistence::ObjectNotFoundError)
|
|
71
|
+
end
|
|
72
|
+
alias find_file_set find_resource
|
|
73
|
+
|
|
74
|
+
def find_files(file_set:)
|
|
75
|
+
each_service_result { |service| service.custom_queries.find_files(file_set:).to_a }.flatten
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
def find_original_file(file_set:)
|
|
79
|
+
each_service_result { |service| service.custom_queries.find_original_file(file_set:) }.first
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
# Each service's non-nil result; raises ObjectNotFoundError only when every service raised it.
|
|
83
|
+
def each_service_result
|
|
84
|
+
errors = []
|
|
85
|
+
results = query_services.filter_map do |service|
|
|
86
|
+
yield service
|
|
87
|
+
rescue Valkyrie::Persistence::ObjectNotFoundError => e
|
|
88
|
+
errors << e
|
|
89
|
+
nil
|
|
90
|
+
end
|
|
91
|
+
raise errors.first if results.empty? && errors.any?
|
|
92
|
+
|
|
93
|
+
results
|
|
94
|
+
end
|
|
95
|
+
|
|
67
96
|
def query_services
|
|
68
97
|
service = Hyrax.query_service
|
|
69
98
|
services = service.respond_to?(:services) ? service.services : [service]
|