projects
/
arvados.git
/ blobdiff
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
13208: Refactor permission checking to improve query performance
[arvados.git]
/
services
/
api
/
lib
/
sweep_trashed_collections.rb
diff --git
a/services/api/lib/sweep_trashed_collections.rb
b/services/api/lib/sweep_trashed_collections.rb
index ab2d27af31b84a2ddb3ad1ed0528eda61cc5632a..a899191db014286c40ea2a5bca5373b3768e3191 100644
(file)
--- a/
services/api/lib/sweep_trashed_collections.rb
+++ b/
services/api/lib/sweep_trashed_collections.rb
@@
-1,3
+1,7
@@
+# Copyright (C) The Arvados Authors. All rights reserved.
+#
+# SPDX-License-Identifier: AGPL-3.0
+
require 'current_api_client'
module SweepTrashedCollections
require 'current_api_client'
module SweepTrashedCollections
@@
-5,10
+9,10
@@
module SweepTrashedCollections
def self.sweep_now
act_as_system_user do
def self.sweep_now
act_as_system_user do
- Collection.
unscoped.
+ Collection.
where('delete_at is not null and delete_at < statement_timestamp()').
destroy_all
where('delete_at is not null and delete_at < statement_timestamp()').
destroy_all
- Collection.
unscoped.
+ Collection.
where('is_trashed = false and trash_at < statement_timestamp()').
update_all('is_trashed = true')
end
where('is_trashed = false and trash_at < statement_timestamp()').
update_all('is_trashed = true')
end
@@
-23,8
+27,11
@@
module SweepTrashedCollections
end
if need
Thread.new do
end
if need
Thread.new do
+ Thread.current.abort_on_exception = false
begin
sweep_now
begin
sweep_now
+ rescue => e
+ Rails.logger.error "#{e.class}: #{e}\n#{e.backtrace.join("\n\t")}"
ensure
ActiveRecord::Base.connection.close
end
ensure
ActiveRecord::Base.connection.close
end