0
0
Fork 0

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
This commit is contained in:
ThibG 2020-05-09 21:06:55 +02:00 committed by GitHub
parent 38b69512ff
commit 34756cc4e0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 1 deletions

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