-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create derivatives from the original
Not from a copy retrieved from the repository This makes importing faster as less network traffic is required.
- Loading branch information
Showing
23 changed files
with
288 additions
and
204 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,12 @@ | ||
class CharacterizeJob < ActiveFedoraIdBasedJob | ||
queue_as :characterize | ||
|
||
def perform(id) | ||
# @param [String] id | ||
# @param [String] filename a local filepath of whicih to characterize. By using this, we don't have to pull a copy out of fedora. | ||
def perform(id, filename) | ||
@id = id | ||
CurationConcerns::CharacterizationService.run(generic_file) | ||
CurationConcerns::CharacterizationService.run(generic_file, filename) | ||
generic_file.save | ||
CreateDerivativesJob.perform_later(generic_file.id) | ||
CreateDerivativesJob.perform_later(generic_file.id, filename) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,10 @@ | ||
class CreateDerivativesJob < ActiveFedoraIdBasedJob | ||
queue_as :derivatives | ||
|
||
def perform(id) | ||
def perform(id, file_name) | ||
@id = id | ||
return unless generic_file.original_file.has_content? | ||
return unless CurationConcerns.config.enable_ffmpeg if generic_file.video? | ||
return if generic_file.video? && !CurationConcerns.config.enable_ffmpeg | ||
|
||
generic_file.create_derivatives | ||
generic_file.save | ||
generic_file.create_derivatives(file_name) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
class IngestFileJob < ActiveJob::Base | ||
queue_as :ingest | ||
|
||
def perform(generic_file_id, filename, mime_type, user_key) | ||
generic_file = GenericFile.find(generic_file_id) | ||
file = Hydra::Derivatives::IoDecorator.new(File.open(filename, "rb")) | ||
file.mime_type = mime_type | ||
file.original_name = File.basename(filename) | ||
|
||
# Tell UploadFileToGenericFile service to skip versioning because versions will be minted by VersionCommitter (called by save_characterize_and_record_committer) when necessary | ||
Hydra::Works::UploadFileToGenericFile.call(generic_file, file, versioning: false) | ||
generic_file.save! | ||
CurationConcerns::VersioningService.create(generic_file.original_file, user_key) | ||
|
||
return unless CurationConcerns.config.respond_to?(:after_create_content) | ||
CurationConcerns.config.after_create_content.call(generic_file, user_key) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
curation_concerns-models/app/services/curation_concerns/local_file_service.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
module CurationConcerns | ||
class LocalFileService | ||
# @param [String] file_name path to the file | ||
# @param [Hash] _options | ||
# @yield [File] opens the file and yields it to the block | ||
def self.call(file_name, _options) | ||
yield File.open(file_name) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.