Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
mastodon
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Pierre Boudes
mastodon
Commits
e682975a
Unverified
Commit
e682975a
authored
2 years ago
by
Jeong Arm
Committed by
GitHub
2 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Add '--days' option to tootctl media refresh (#18425)
* Add '--days' option to tootctl media refresh * Fix undefined scope
parent
63a5514b
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
lib/mastodon/media_cli.rb
+9
-0
9 additions, 0 deletions
lib/mastodon/media_cli.rb
with
9 additions
and
0 deletions
lib/mastodon/media_cli.rb
+
9
−
0
View file @
e682975a
...
...
@@ -187,6 +187,7 @@ module Mastodon
option
:account
,
type: :string
option
:domain
,
type: :string
option
:status
,
type: :numeric
option
:days
,
type: :numeric
option
:concurrency
,
type: :numeric
,
default:
5
,
aliases:
[
:c
]
option
:verbose
,
type: :boolean
,
default:
false
,
aliases:
[
:v
]
option
:dry_run
,
type: :boolean
,
default:
false
...
...
@@ -204,6 +205,8 @@ module Mastodon
Use the --domain option to download attachments from a specific domain.
Use the --days option to limit attachments created within days.
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
...
...
@@ -224,10 +227,16 @@ module Mastodon
scope
=
MediaAttachment
.
where
(
account_id:
account
.
id
)
elsif
options
[
:domain
]
scope
=
MediaAttachment
.
joins
(
:account
).
merge
(
Account
.
by_domain_and_subdomains
(
options
[
:domain
]))
elsif
options
[
:days
].
present?
scope
=
MediaAttachment
.
remote
else
exit
(
1
)
end
if
options
[
:days
].
present?
scope
=
scope
.
where
(
'id > ?'
,
Mastodon
::
Snowflake
.
id_at
(
options
[
:days
].
days
.
ago
,
with_random:
false
))
end
processed
,
aggregate
=
parallelize_with_progress
(
scope
)
do
|
media_attachment
|
next
if
media_attachment
.
remote_url
.
blank?
||
(
!
options
[
:force
]
&&
media_attachment
.
file_file_name
.
present?
)
next
if
DomainBlock
.
reject_media?
(
media_attachment
.
account
.
domain
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment