mirror of
https://github.com/mastodon/mastodon.git
synced 2025-07-13 07:48:15 +00:00
Compare commits
10 Commits
54c4fb50b6
...
7ae78feba3
Author | SHA1 | Date | |
---|---|---|---|
![]() |
7ae78feba3 | ||
![]() |
b23a68168a | ||
![]() |
bd769970fa | ||
![]() |
bb04f0b561 | ||
![]() |
ba3e30cf93 | ||
![]() |
b9638a6b82 | ||
![]() |
6434d8ab4b | ||
![]() |
a5ac53d326 | ||
![]() |
fbaca0c953 | ||
![]() |
03f888806a |
|
@ -142,7 +142,41 @@ module Mastodon::CLI
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
when :fog
|
when :fog
|
||||||
fail_with_message 'The fog storage driver is not supported for this operation at this time'
|
fog_directory = Paperclip::Attachment.default_options[:fog_directory]
|
||||||
|
connection = Fog::Storage.new(Paperclip::Attachment.default_options[:fog_credentials])
|
||||||
|
directory = connection.directories.get(fog_directory)
|
||||||
|
last_key = options[:start_after]
|
||||||
|
|
||||||
|
loop do
|
||||||
|
objects = begin
|
||||||
|
directory.files.all(prefix: prefix, marker: last_key, limit: 1000).to_a
|
||||||
|
rescue => e
|
||||||
|
progress.log(pastel.red("Error fetching list of files: #{e}"))
|
||||||
|
progress.log("If you want to continue from this point, add --start-after=#{last_key} to your command") if last_key
|
||||||
|
break
|
||||||
|
end
|
||||||
|
|
||||||
|
break if objects.empty?
|
||||||
|
|
||||||
|
last_key = objects.last.key
|
||||||
|
|
||||||
|
objects.each do |object|
|
||||||
|
path_segments = object.key.split('/')
|
||||||
|
progress.increment
|
||||||
|
next unless orphaned_file?(path_segments)
|
||||||
|
|
||||||
|
begin
|
||||||
|
object.destroy unless dry_run?
|
||||||
|
reclaimed_bytes += object.content_length
|
||||||
|
removed += 1
|
||||||
|
progress.log("Found and removed orphan: #{object.key}")
|
||||||
|
rescue => e
|
||||||
|
progress.log(pastel.red("Error processing #{object.key}: #{e}"))
|
||||||
|
end
|
||||||
|
rescue UnrecognizedOrphanType
|
||||||
|
progress.log(pastel.yellow("Unrecognized file found: #{object.key}"))
|
||||||
|
end
|
||||||
|
end
|
||||||
when :azure
|
when :azure
|
||||||
fail_with_message 'The azure storage driver is not supported for this operation at this time'
|
fail_with_message 'The azure storage driver is not supported for this operation at this time'
|
||||||
when :filesystem
|
when :filesystem
|
||||||
|
|
Loading…
Reference in New Issue
Block a user