curation_concerns 1.7.6 → 1.7.7

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: 6b30d38b53d476bbfc1cea73a8c9133349ceed15
4
- data.tar.gz: 92b2af16e5151eac8855e9964574630497748b06
3
+ metadata.gz: 60d64b0327762c6a74445d94e7933ac8fe6003e7
4
+ data.tar.gz: 8af9f568602191a9afaaa3fcee090c1e88ed4f67
5
5
  SHA512:
6
- metadata.gz: 65d9dc94b9086238326a41247bb27f20dcb5111efe60b2aeb2a57b23dcb4b0a5fff9e10c923dccc6611679a043231b2c14912c7b9b2ce720372b643535033051
7
- data.tar.gz: 601036a1bd6a491062a0e8cfde977d46c08f915248d8811bf7555a9122bfcfd49779a045b52751732c7a30092107a338298b82c2fa2ce9538d36cce3b95e94d3
6
+ metadata.gz: f891d3bff4d44ed3a89b21911341304ac843466bda847cf5ba284e09690c708ee5e7efe069a2c99c36700342bf0ad211a15a4f5d077bdc9cf8ac99b99a1aba0d
7
+ data.tar.gz: 0819ec209d2471aec58f0c5c57cfc6cf16eaf28ec8fb61464653c400a873cfcd56aff481a3a60799a8fa0239c5cefb7f58aa04240782b1842d6d071779456366
data/.travis.yml CHANGED
@@ -1,8 +1,12 @@
1
1
  language: ruby
2
2
  cache: bundler
3
3
  sudo: false
4
+
4
5
  rvm:
5
6
  - 2.3.1
7
+
8
+ services: redis
9
+
6
10
  env:
7
11
  global:
8
12
  - NOKOGIRI_USE_SYSTEM_LIBRARIES=true
@@ -11,5 +15,6 @@ env:
11
15
  RDF_VERSION=1.99.1
12
16
  - RAILS_VERSION=5.0.0.1
13
17
  RDF_VERSION=2.1.1
18
+
14
19
  before_script:
15
20
  - jdk_switcher use oraclejdk8
@@ -1,4 +1,6 @@
1
1
  class CharacterizeJob < ActiveJob::Base
2
+ include CurationConcerns::Lockable
3
+
2
4
  queue_as CurationConcerns.config.ingest_queue_name
3
5
 
4
6
  # @param [FileSet] file_set
@@ -7,11 +9,16 @@ class CharacterizeJob < ActiveJob::Base
7
9
  def perform(file_set, file_id, filepath = nil)
8
10
  filename = CurationConcerns::WorkingDirectory.find_or_retrieve(file_id, file_set.id, filepath)
9
11
  raise LoadError, "#{file_set.class.characterization_proxy} was not found" unless file_set.characterization_proxy?
10
- Hydra::Works::CharacterizationService.run(file_set.characterization_proxy, filename)
11
- Rails.logger.debug "Ran characterization on #{file_set.characterization_proxy.id} (#{file_set.characterization_proxy.mime_type})"
12
- file_set.characterization_proxy.save!
13
- file_set.update_index
14
- file_set.parent.in_collections.each(&:update_index) if file_set.parent
12
+
13
+ # Prevent other jobs from trying to modify the FileSet at the same time
14
+ acquire_lock_for(file_set.id) do
15
+ Hydra::Works::CharacterizationService.run(file_set.characterization_proxy, filename)
16
+ Rails.logger.debug "Ran characterization on #{file_set.characterization_proxy.id} (#{file_set.characterization_proxy.mime_type})"
17
+ file_set.characterization_proxy.save!
18
+ file_set.update_index
19
+ file_set.parent.in_collections.each(&:update_index) if file_set.parent
20
+ end
21
+
15
22
  CreateDerivativesJob.perform_later(file_set, file_id, filename)
16
23
  end
17
24
  end
@@ -1,4 +1,6 @@
1
1
  class CreateDerivativesJob < ActiveJob::Base
2
+ include CurationConcerns::Lockable
3
+
2
4
  queue_as CurationConcerns.config.ingest_queue_name
3
5
 
4
6
  # @param [FileSet] file_set
@@ -8,12 +10,15 @@ class CreateDerivativesJob < ActiveJob::Base
8
10
  return if file_set.video? && !CurationConcerns.config.enable_ffmpeg
9
11
  filename = CurationConcerns::WorkingDirectory.find_or_retrieve(file_id, file_set.id, filepath)
10
12
 
11
- file_set.create_derivatives(filename)
13
+ # Prevent other jobs from trying to modify the FileSet at the same time
14
+ acquire_lock_for(file_set.id) do
15
+ file_set.create_derivatives(filename)
12
16
 
13
- # Reload from Fedora and reindex for thumbnail and extracted text
14
- file_set.reload
15
- file_set.update_index
16
- file_set.parent.update_index if parent_needs_reindex?(file_set)
17
+ # Reload from Fedora and reindex for thumbnail and extracted text
18
+ file_set.reload
19
+ file_set.update_index
20
+ file_set.parent.update_index if parent_needs_reindex?(file_set)
21
+ end
17
22
  end
18
23
 
19
24
  # If this file_set is the thumbnail for the parent work,
@@ -1,4 +1,6 @@
1
1
  class IngestFileJob < ActiveJob::Base
2
+ include CurationConcerns::Lockable
3
+
2
4
  queue_as CurationConcerns.config.ingest_queue_name
3
5
 
4
6
  # @param [FileSet] file_set
@@ -15,15 +17,17 @@ class IngestFileJob < ActiveJob::Base
15
17
  local_file.mime_type = opts.fetch(:mime_type, nil)
16
18
  local_file.original_name = opts.fetch(:filename, File.basename(filepath))
17
19
 
18
- # Tell AddFileToFileSet service to skip versioning because versions will be minted by
19
- # VersionCommitter when necessary during save_characterize_and_record_committer.
20
- Hydra::Works::AddFileToFileSet.call(file_set,
21
- local_file,
22
- relation,
23
- versioning: false)
24
-
25
- # Persist changes to the file_set
26
- file_set.save!
20
+ # Prevent other jobs from trying to modify the FileSet at the same time
21
+ acquire_lock_for(file_set.id) do
22
+ # Tell AddFileToFileSet service to skip versioning because versions will be minted by
23
+ # VersionCommitter when necessary during save_characterize_and_record_committer.
24
+ Hydra::Works::AddFileToFileSet.call(file_set,
25
+ local_file,
26
+ relation,
27
+ versioning: false)
28
+ # Persist changes to the file_set
29
+ file_set.save!
30
+ end
27
31
 
28
32
  repository_file = file_set.send(relation)
29
33
 
@@ -4,7 +4,7 @@ module CurationConcerns
4
4
  # grants the creator the ability to alter it.
5
5
  class GrantEditToDepositor
6
6
  def self.call(target:, **)
7
- target.edit_users = [target.depositor]
7
+ target.edit_users += [target.depositor]
8
8
  end
9
9
  end
10
10
  end
@@ -1,3 +1,3 @@
1
1
  module CurationConcerns
2
- VERSION = '1.7.6'.freeze
2
+ VERSION = '1.7.7'.freeze
3
3
  end
@@ -2,7 +2,6 @@ require 'spec_helper'
2
2
 
3
3
  RSpec.describe CurationConcerns::Workflow::GrantEditToDepositor do
4
4
  let(:depositor) { create(:user) }
5
- let(:work) { create(:work_without_access, depositor: depositor.user_key) }
6
5
  let(:user) { User.new }
7
6
 
8
7
  describe ".call" do
@@ -12,9 +11,21 @@ RSpec.describe CurationConcerns::Workflow::GrantEditToDepositor do
12
11
  user: user)
13
12
  end
14
13
 
15
- it "adds edit access " do
16
- expect { subject }.to change { work.edit_users }.from([]).to([depositor.user_key])
17
- expect(work).to be_valid
14
+ context "with no additional editors" do
15
+ let(:work) { create(:work_without_access, depositor: depositor.user_key) }
16
+ it "adds edit access" do
17
+ expect { subject }.to change { work.edit_users }.from([]).to([depositor.user_key])
18
+ expect(work).to be_valid
19
+ end
20
+ end
21
+
22
+ context "with an additional editor" do
23
+ let(:editor) { create(:user) }
24
+ let(:work) { create(:work_without_access, depositor: depositor.user_key, edit_users: [editor.user_key]) }
25
+ it "adds edit access" do
26
+ expect { subject }.to change { work.edit_users }.from([editor.user_key]).to([editor.user_key, depositor.user_key])
27
+ expect(work).to be_valid
28
+ end
18
29
  end
19
30
  end
20
31
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: curation_concerns
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.7.6
4
+ version: 1.7.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Zumwalt
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2017-03-10 00:00:00.000000000 Z
13
+ date: 2017-04-24 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: hydra-head