cdm_migrator 3.4.2 → 3.5.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
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9bd9baa9f5c277e22421a1726d4652d2231a4067aabcf2e4f048ac9aa7264fc2
|
4
|
+
data.tar.gz: f698973f8726c227326fd7e0c393af4201c7dd9352f43d669cff9659f310da85
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6c264c4d7a122f598aef1d746766771b408defb9a15e014490f7a2acd43772197c5e66d15a99120c13089f013fe702f9dc5aeaebbb9cbc9f70b2110b54cac55d
|
7
|
+
data.tar.gz: 85241bcb0111ead83629678cfde68fb729d49997890dbc0432857e6f7976f74f3f4296b0e6aecac309b71a84b398ea02fa24f1d346d652912a60eded09c39c0c
|
@@ -14,32 +14,59 @@ module CdmMigrator
|
|
14
14
|
# advantage of the same strategy as Hyrax::Actors::FileSetOrderedMembersActor
|
15
15
|
# but you don't need the OrderedMembersActor constant initialized.
|
16
16
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
17
|
+
def perform work, ingest_work, user
|
18
|
+
# Reload the work to get the most recent and accurate member associations
|
19
|
+
work.reload
|
20
|
+
if work.ordered_members.to_a.empty? && work.file_sets.empty?
|
21
|
+
attach_files(work, ingest_work.files, user)
|
22
|
+
else
|
23
|
+
delete_excess_file_sets(work)
|
24
|
+
ordered_count = work.reload.ordered_members.to_a.count
|
25
|
+
unless ordered_count == ingest_work.files.count
|
26
|
+
# Attach any files that might be missing
|
27
|
+
files = ingest_work[ordered_count..]
|
28
|
+
attach_files(work, files, user)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
first_file_set = work.ordered_members.to_a.first
|
32
|
+
work.representative = first_file_set
|
33
|
+
work.thumbnail = first_file_set
|
34
|
+
work.save!
|
35
|
+
work.file_sets.each { |fs| CdmIngestFilesJob.perform_later(fs, fs.import_url, user, ingest_work) }
|
23
36
|
end
|
24
37
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
38
|
+
private
|
39
|
+
|
40
|
+
def attach_files(work, ingest_work_files, user)
|
41
|
+
ingest_work_files.each do |file|
|
42
|
+
url = file[:url]
|
43
|
+
ordered_members = work.ordered_members
|
44
|
+
# last_file = ingest_work.files.last==file
|
45
|
+
::FileSet.new(import_url: url, label: file[:title]) do |fs|
|
46
|
+
fs.attributes = file[:metadata]
|
47
|
+
fs.save!
|
48
|
+
ordered_members << fs
|
35
49
|
end
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
50
|
+
end
|
51
|
+
work.save!
|
52
|
+
work.reload.ordered_members.to_a.each do |file_set|
|
53
|
+
Hyrax.config.callback.run(:after_create_fileset, file_set, user, warn: false)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
# Sometimes when this job fails, file sets are attached to the work
|
58
|
+
# without attaching them as ordered members. This creates "ghost files"
|
59
|
+
# that don't show up in the interface but are still linked to the work as members
|
60
|
+
def delete_excess_file_sets(work)
|
61
|
+
ordered_members = work.ordered_members.to_a
|
62
|
+
ghost_members = work.file_sets.select { |fs| ordered_members.exclude? fs }
|
63
|
+
if ghost_members.any?
|
64
|
+
# Unlink the file sets from the parent work first because it makes deleting them faster
|
65
|
+
work.members = ordered_members
|
40
66
|
work.save!
|
41
|
-
|
67
|
+
ghost_members.each(&:destroy!)
|
68
|
+
end
|
42
69
|
end
|
43
|
-
|
70
|
+
|
44
71
|
end
|
45
72
|
end
|
data/lib/cdm_migrator/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cdm_migrator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.5.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- sephirothkod
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-07-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|