Browse Source

Fix "tootctl media remove-orphans" crashing on “Import” files (#13685)

* Fix "tootctl media remove-orphans" crashing on “Import” files

* Also remove empty directories when removing orphaned media
closed-social-v3
ThibG 4 years ago
committed by GitHub
parent
commit
34756cc4e0
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 1 deletions
  1. +2
    -0
      config/initializers/inflections.rb
  2. +8
    -1
      lib/mastodon/media_cli.rb

+ 2
- 0
config/initializers/inflections.rb View File

@ -19,4 +19,6 @@ ActiveSupport::Inflector.inflections(:en) do |inflect|
inflect.acronym 'ActivityStreams'
inflect.acronym 'JsonLd'
inflect.acronym 'NodeInfo'
inflect.singular 'data', 'data'
end

+ 8
- 1
lib/mastodon/media_cli.rb View File

@ -144,7 +144,14 @@ module Mastodon
begin
size = File.size(path)
File.delete(path) unless options[:dry_run]
unless options[:dry_run]
File.delete(path)
begin
FileUtils.rmdir(File.dirname(path), parents: true)
rescue Errno::ENOTEMPTY
# OK
end
end
reclaimed_bytes += size
removed += 1

Loading…
Cancel
Save