about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--config/initializers/inflections.rb2
-rw-r--r--lib/mastodon/media_cli.rb9
2 files changed, 10 insertions, 1 deletions
diff --git a/config/initializers/inflections.rb b/config/initializers/inflections.rb
index c65153b0a..0667a542c 100644
--- a/config/initializers/inflections.rb
+++ b/config/initializers/inflections.rb
@@ -19,4 +19,6 @@ ActiveSupport::Inflector.inflections(:en) do |inflect|
   inflect.acronym 'ActivityStreams'
   inflect.acronym 'JsonLd'
   inflect.acronym 'NodeInfo'
+
+  inflect.singular 'data', 'data'
 end
diff --git a/lib/mastodon/media_cli.rb b/lib/mastodon/media_cli.rb
index 424d65a5f..506544446 100644
--- a/lib/mastodon/media_cli.rb
+++ b/lib/mastodon/media_cli.rb
@@ -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