Skip to content

Commit

Permalink
Merge pull request #1316 from sul-dlss/remove-zipline
Browse files Browse the repository at this point in the history
Remove dependency on zipline
  • Loading branch information
jcoyne authored Dec 3, 2024
2 parents 68583ea + ca5f62f commit 1dfaf4d
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 19 deletions.
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ gem 'http'
gem 'cancancan'
gem 'dalli'
gem 'retries'
gem 'zipline', '~> 2.0'
gem 'zip_kit', '~> 6.3'
gem 'jwt'
gem 'redis'

Expand Down
7 changes: 1 addition & 6 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,6 @@ GEM
deep_merge (~> 1.2, >= 1.2.1)
ostruct
connection_pool (2.4.1)
content_disposition (1.0.0)
crack (1.0.0)
bigdecimal
rexml
Expand Down Expand Up @@ -397,10 +396,6 @@ GEM
nokogiri (~> 1.8)
zeitwerk (2.7.1)
zip_kit (6.3.1)
zipline (2.0.0)
actionpack (>= 6.0, < 8.0)
content_disposition (~> 1.0)
zip_kit (~> 6, >= 6.2.0, < 7)

PLATFORMS
arm64-darwin-23
Expand Down Expand Up @@ -449,7 +444,7 @@ DEPENDENCIES
web-console (>= 4.1.0)
webdrivers
webmock (~> 3.0)
zipline (~> 2.0)
zip_kit (~> 6.3)

BUNDLED WITH
2.5.14
25 changes: 13 additions & 12 deletions app/controllers/object_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
##
# API for delivering whole objects from stacks
class ObjectController < ApplicationController
include Zipline

# Return a zip of all the files if they have access to all the files.
# This will force a login if any of the files is not access=world
def show
Expand All @@ -15,25 +13,28 @@ def show
files.each do |file|
authorize! :download, file
end
zip_contents = files.map do |file|
[
file,
file.file_name,
modification_time: file.mtime
]

track_download

zip_kit_stream(filename: "#{druid}.zip") do |zip|
files.each do |stacks_file|
zip.write_file(stacks_file.file_name, modification_time: stacks_file.mtime) do |sink|
File.open(stacks_file.path, "rb") { |file_input| IO.copy_stream(file_input, sink) }
end
end
end
end

private

def track_download
TrackDownloadJob.perform_later(
druid:,
user_agent: request.user_agent,
ip: request.remote_ip
)

zipline(zip_contents, "#{druid}.zip")
end

private

def druid
params[:id]
end
Expand Down
2 changes: 2 additions & 0 deletions app/models/cocina.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ class Cocina

THUMBNAIL_MIME_TYPE = 'image/jp2'

# @return [Cocina] Returns the cocina object for the given druid and version
def self.find(druid, version = :head)
data = Rails.cache.fetch(metadata_cache_key(druid, version), expires_in: 10.minutes) do
benchmark "Fetching public json for #{druid} version #{version}" do
Expand Down Expand Up @@ -73,6 +74,7 @@ def embargo_release_date
data.dig('access', 'embargo', 'releaseDate')
end

# @return [Enumerator<StacksFile>] when no block is passed
def files(&)
return to_enum(:files) unless block_given?

Expand Down

0 comments on commit 1dfaf4d

Please sign in to comment.