Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tootctl media remove-orphans #12568

Merged
merged 1 commit into from
Dec 8, 2019

Conversation

Gargron
Copy link
Member

@Gargron Gargron commented Dec 8, 2019

Scans file storage for files that do not belong to existing media attachments. Because this operation
requires iterating over every single file individually, it will be slow.

Please mind that some storage providers charge for the necessary API requests to list objects.

@Gargron Gargron added the moderation Administration and moderation tooling label Dec 8, 2019
@Gargron Gargron force-pushed the feature-tootctl-media-remove-orphans branch 6 times, most recently from 5edff69 to 49a1dd4 Compare December 8, 2019 02:46
Copy link
Member

@nightpool nightpool left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

code lgtm % comments

@@ -89,7 +89,7 @@
Paperclip::Attachment.default_options.merge!(
storage: :filesystem,
use_timestamp: true,
path: ENV.fetch('PAPERCLIP_ROOT_PATH', ':rails_root/public/system') + '/:class/:attachment/:id_partition/:style/:filename',
path: File.join(ENV.fetch('PAPERCLIP_ROOT_PATH', File.join(':rails_root', 'public', 'system')), ':class', ':attachment', ':id_partition', ':style', ':filename'),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

*%w(:rails_root public system) can clean up these arg lists

progress = create_progress_bar(nil)
reclaimed_bytes = 0
removed = 0
dry_run = options[:dry_run] ? ' (DRY RUN)' : ''
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe we should make this :destructive so it's opt in instead of opt out?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or maybe we should gather all the files to delete, ask for confirmation, and then delete them

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wouldn't do that because of memory implications if there are a lot of files as well as being able to interrupt the process while having some kind of tangible progress.

@Gargron Gargron force-pushed the feature-tootctl-media-remove-orphans branch 3 times, most recently from c3ef226 to 2bf3ecb Compare December 8, 2019 03:06
@Gargron Gargron force-pushed the feature-tootctl-media-remove-orphans branch from 2bf3ecb to 11a34e9 Compare December 8, 2019 03:12
@Gargron Gargron merged commit f3d2323 into master Dec 8, 2019
@Gargron Gargron deleted the feature-tootctl-media-remove-orphans branch December 8, 2019 14:37
@angristan
Copy link
Contributor

Thanks for this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
moderation Administration and moderation tooling
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants