Clarify preview card CLI command handles media only (#39348)

This commit is contained in:
Matt Jankowski 2026-06-10 05:27:07 -04:00 committed by GitHub
parent 885a9f1d84
commit c51eb56a90
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 11 additions and 12 deletions

View File

@ -11,18 +11,17 @@ module Mastodon::CLI
option :verbose, type: :boolean, aliases: [:v]
option :dry_run, type: :boolean, default: false
option :link, type: :boolean, default: false
desc 'remove', 'Remove preview cards'
desc 'remove', 'Remove preview card media'
long_desc <<-DESC
Removes local thumbnails for preview cards.
The --days option specifies how old preview cards have to be before
they are removed. It defaults to 180 days. Since preview cards will
not be re-fetched unless the link is re-posted after 2 weeks from
last time, it is not recommended to delete preview cards within the
last 14 days.
The --days option sets the age a preview card must be before attached
media will be removed. Preview cards will not be re-fetched unless the
link is posted again two weeks after the last usage, so it is not
recommended to delete preview card media from within the last 14 days.
With the --link option, only link-type preview cards will be deleted,
leaving video and photo cards untouched.
With the --link option, only media from link-type preview cards will be
deleted, skipping video and photo cards.
DESC
def remove
time_ago = options[:days].days.ago
@ -44,7 +43,7 @@ module Mastodon::CLI
size
end
say("Removed #{processed} #{link}preview cards (approx. #{number_to_human_size(aggregate)})#{dry_run_mode_suffix}", :green, true)
say("Removed media from #{processed} #{link}preview cards (approx. #{number_to_human_size(aggregate)})#{dry_run_mode_suffix}", :green, true)
end
end
end

View File

@ -26,7 +26,7 @@ RSpec.describe Mastodon::CLI::PreviewCards do
it 'deletes thumbnails for local preview cards' do
expect { subject }
.to output_results(
'Removed 2 preview cards',
'Removed media from 2 preview cards',
'approx. 119 KB'
)
end
@ -38,7 +38,7 @@ RSpec.describe Mastodon::CLI::PreviewCards do
it 'deletes thumbnails for local preview cards' do
expect { subject }
.to output_results(
'Removed 1 link-type preview cards',
'Removed media from 1 link-type preview cards',
'approx. 59.6 KB'
)
end
@ -50,7 +50,7 @@ RSpec.describe Mastodon::CLI::PreviewCards do
it 'deletes thumbnails for local preview cards' do
expect { subject }
.to output_results(
'Removed 1 preview cards',
'Removed media from 1 preview cards',
'approx. 59.6 KB'
)
end