about summary refs log tree commit diff
path: root/lib
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2019-10-08 05:59:10 +0200
committerGitHub <noreply@github.com>2019-10-08 05:59:10 +0200
commit4a98e77d0e7fec15e1830059a9a56bf56aa391db (patch)
tree53402374a2b9b211769f9645db51812ab4970903 /lib
parent0aaa3afc2df2cc2fa8cdd277cf91dcfabf45afcd (diff)
Change `tootctl media refresh` to skip already downloaded attachments (#12118)
Diffstat (limited to 'lib')
-rw-r--r--lib/mastodon/media_cli.rb6
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/mastodon/media_cli.rb b/lib/mastodon/media_cli.rb
index bb97751d5..e48175134 100644
--- a/lib/mastodon/media_cli.rb
+++ b/lib/mastodon/media_cli.rb
@@ -50,6 +50,7 @@ module Mastodon
     option :concurrency, type: :numeric, default: 5, aliases: [:c]
     option :verbose, type: :boolean, default: false, aliases: [:v]
     option :dry_run, type: :boolean, default: false
+    option :force, type: :boolean, default: false
     desc 'refresh', 'Fetch remote media files'
     long_desc <<-DESC
       Re-downloads media attachments from other servers. You must specify the
@@ -62,6 +63,9 @@ module Mastodon
       using username@domain handle of the account.
 
       Use the --domain option to download attachments from a specific domain.
+
+      By default, attachments that are believed to be already downloaded will
+      not be re-downloaded. To force re-download of every URL, use --force.
     DESC
     def refresh
       dry_run = options[:dry_run] ? ' (DRY RUN)' : ''
@@ -85,7 +89,7 @@ module Mastodon
       end
 
       processed, aggregate = parallelize_with_progress(scope) do |media_attachment|
-        next if media_attachment.remote_url.blank?
+        next if media_attachment.remote_url.blank? || (!options[:force] && media_attachment.file_file_name.present?)
 
         unless options[:dry_run]
           media_attachment.reset_file!