forked from fedi/mastodon
Fix tootctl media remove-orphans
choking on unknown files in storage (#13765)
Fix #13762 Catch tootctl interrupt to prevent confusing stacktrace
This commit is contained in:
parent
2b91a3dac0
commit
199bbbcb9f
|
@ -1,5 +1,11 @@
|
||||||
#!/usr/bin/env ruby
|
#!/usr/bin/env ruby
|
||||||
APP_PATH = File.expand_path('../config/application', __dir__)
|
APP_PATH = File.expand_path('../config/application', __dir__)
|
||||||
|
|
||||||
require_relative '../config/boot'
|
require_relative '../config/boot'
|
||||||
require_relative '../lib/cli'
|
require_relative '../lib/cli'
|
||||||
Mastodon::CLI.start(ARGV)
|
|
||||||
|
begin
|
||||||
|
Mastodon::CLI.start(ARGV)
|
||||||
|
rescue Interrupt
|
||||||
|
exit(130)
|
||||||
|
end
|
||||||
|
|
|
@ -88,6 +88,11 @@ module Mastodon
|
||||||
path_segments = object.key.split('/')
|
path_segments = object.key.split('/')
|
||||||
path_segments.delete('cache')
|
path_segments.delete('cache')
|
||||||
|
|
||||||
|
if path_segments.size != 7
|
||||||
|
progress.log(pastel.yellow("Unrecognized file found: #{object.key}"))
|
||||||
|
next
|
||||||
|
end
|
||||||
|
|
||||||
model_name = path_segments.first.classify
|
model_name = path_segments.first.classify
|
||||||
attachment_name = path_segments[1].singularize
|
attachment_name = path_segments[1].singularize
|
||||||
record_id = path_segments[2..-2].join.to_i
|
record_id = path_segments[2..-2].join.to_i
|
||||||
|
@ -127,6 +132,11 @@ module Mastodon
|
||||||
path_segments = key.split(File::SEPARATOR)
|
path_segments = key.split(File::SEPARATOR)
|
||||||
path_segments.delete('cache')
|
path_segments.delete('cache')
|
||||||
|
|
||||||
|
if path_segments.size != 7
|
||||||
|
progress.log(pastel.yellow("Unrecognized file found: #{key}"))
|
||||||
|
next
|
||||||
|
end
|
||||||
|
|
||||||
model_name = path_segments.first.classify
|
model_name = path_segments.first.classify
|
||||||
record_id = path_segments[2..-2].join.to_i
|
record_id = path_segments[2..-2].join.to_i
|
||||||
attachment_name = path_segments[1].singularize
|
attachment_name = path_segments[1].singularize
|
||||||
|
@ -246,6 +256,11 @@ module Mastodon
|
||||||
path_segments = path.split('/')[2..-1]
|
path_segments = path.split('/')[2..-1]
|
||||||
path_segments.delete('cache')
|
path_segments.delete('cache')
|
||||||
|
|
||||||
|
if path_segments.size != 7
|
||||||
|
say('Not a media URL', :red)
|
||||||
|
exit(1)
|
||||||
|
end
|
||||||
|
|
||||||
model_name = path_segments.first.classify
|
model_name = path_segments.first.classify
|
||||||
record_id = path_segments[2..-2].join.to_i
|
record_id = path_segments[2..-2].join.to_i
|
||||||
|
|
||||||
|
@ -294,6 +309,8 @@ module Mastodon
|
||||||
segments = object.key.split('/')
|
segments = object.key.split('/')
|
||||||
segments.delete('cache')
|
segments.delete('cache')
|
||||||
|
|
||||||
|
next if segments.size != 7
|
||||||
|
|
||||||
model_name = segments.first.classify
|
model_name = segments.first.classify
|
||||||
record_id = segments[2..-2].join.to_i
|
record_id = segments[2..-2].join.to_i
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue