X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/704dd826a498db11a052fe77a4953b0caa245c10..8c30c649c667f7ccd205cdfcf1864563ac503585:/services/api/app/models/collection.rb diff --git a/services/api/app/models/collection.rb b/services/api/app/models/collection.rb index a088d48e68..ddb85862a2 100644 --- a/services/api/app/models/collection.rb +++ b/services/api/app/models/collection.rb @@ -3,7 +3,7 @@ # SPDX-License-Identifier: AGPL-3.0 require 'arvados/keep' -require 'sweep_trashed_collections' +require 'sweep_trashed_objects' require 'trashable' class Collection < ArvadosModel @@ -94,7 +94,7 @@ class Collection < ArvadosModel # Check permissions on the collection manifest. # If any signature cannot be verified, raise PermissionDeniedError # which will return 403 Permission denied to the client. - api_token = current_api_client_authorization.andand.api_token + api_token = Thread.current[:token] signing_opts = { api_token: api_token, now: @validation_timestamp.to_i, @@ -190,22 +190,16 @@ class Collection < ArvadosModel end def manifest_files + return '' if !self.manifest_text + names = '' - if self.manifest_text - self.manifest_text.scan(/ \d+:\d+:(\S+)/) do |name| - names << name.first.gsub('\040',' ') + "\n" - break if names.length > 2**12 - end + self.manifest_text.scan(/ \d+:\d+:(\S+)/) do |name| + names << name.first.gsub('\040',' ') + "\n" end - - if self.manifest_text and names.length < 2**12 - self.manifest_text.scan(/^\.\/(\S+)/m) do |stream_name| - names << stream_name.first.gsub('\040',' ') + "\n" - break if names.length > 2**12 - end + self.manifest_text.scan(/^\.\/(\S+)/m) do |stream_name| + names << stream_name.first.gsub('\040',' ') + "\n" end - - names[0,2**12] + names end def default_empty_manifest @@ -250,7 +244,7 @@ class Collection < ArvadosModel elsif is_trashed return manifest_text else - token = current_api_client_authorization.andand.api_token + token = Thread.current[:token] exp = [db_current_time.to_i + Rails.configuration.blob_signature_ttl, trash_at].compact.map(&:to_i).min self.class.sign_manifest manifest_text, token, exp @@ -448,7 +442,7 @@ class Collection < ArvadosModel end def self.where *args - SweepTrashedCollections.sweep_if_stale + SweepTrashedObjects.sweep_if_stale super end