From a4cdbc52b17597b7ed37146a93c747d1ec7791b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Misty=20De=20M=C3=A9o?= Date: Thu, 27 Jul 2023 07:13:45 -0700 Subject: [PATCH] Storage: add :azure to remaining callers (#26080) --- app/controllers/backups_controller.rb | 2 +- app/lib/attachment_batch.rb | 3 +++ app/services/suspend_account_service.rb | 2 +- app/services/unsuspend_account_service.rb | 2 +- lib/mastodon/cli/media.rb | 3 +++ lib/mastodon/cli/upgrade.rb | 7 +++++++ 6 files changed, 16 insertions(+), 3 deletions(-) diff --git a/app/controllers/backups_controller.rb b/app/controllers/backups_controller.rb index 205df48d44..db23fefbbc 100644 --- a/app/controllers/backups_controller.rb +++ b/app/controllers/backups_controller.rb @@ -10,7 +10,7 @@ class BackupsController < ApplicationController def download case Paperclip::Attachment.default_options[:storage] - when :s3 + when :s3, :azure redirect_to @backup.dump.expiring_url(10), allow_other_host: true when :fog if Paperclip::Attachment.default_options.dig(:fog_credentials, :openstack_temp_url_key).present? diff --git a/app/lib/attachment_batch.rb b/app/lib/attachment_batch.rb index 1f87b94336..b75938bdd7 100644 --- a/app/lib/attachment_batch.rb +++ b/app/lib/attachment_batch.rb @@ -76,6 +76,9 @@ class AttachmentBatch when :fog logger.debug { "Deleting #{attachment.path(style)}" } attachment.directory.files.new(key: attachment.path(style)).destroy + when :azure + logger.debug { "Deleting #{attachment.path(style)}" } + attachment.destroy end end end diff --git a/app/services/suspend_account_service.rb b/app/services/suspend_account_service.rb index e9e23a219b..9f21fb79bf 100644 --- a/app/services/suspend_account_service.rb +++ b/app/services/suspend_account_service.rb @@ -85,7 +85,7 @@ class SuspendAccountService < BaseService rescue Aws::S3::Errors::NotImplemented => e Rails.logger.error "Error trying to change ACL on #{attachment.s3_object(style).key}: #{e.message}" end - when :fog + when :fog, :azure # Not supported when :filesystem begin diff --git a/app/services/unsuspend_account_service.rb b/app/services/unsuspend_account_service.rb index 51665eab94..e555932f81 100644 --- a/app/services/unsuspend_account_service.rb +++ b/app/services/unsuspend_account_service.rb @@ -81,7 +81,7 @@ class UnsuspendAccountService < BaseService rescue Aws::S3::Errors::NotImplemented => e Rails.logger.error "Error trying to change ACL on #{attachment.s3_object(style).key}: #{e.message}" end - when :fog + when :fog, :azure # Not supported when :filesystem begin diff --git a/lib/mastodon/cli/media.rb b/lib/mastodon/cli/media.rb index 40b270ffb2..c906161770 100644 --- a/lib/mastodon/cli/media.rb +++ b/lib/mastodon/cli/media.rb @@ -158,6 +158,9 @@ module Mastodon::CLI when :fog say('The fog storage driver is not supported for this operation at this time', :red) exit(1) + when :azure + say('The azure storage driver is not supported for this operation at this time', :red) + exit(1) when :filesystem require 'find' diff --git a/lib/mastodon/cli/upgrade.rb b/lib/mastodon/cli/upgrade.rb index 88390da5bf..52b5540c40 100644 --- a/lib/mastodon/cli/upgrade.rb +++ b/lib/mastodon/cli/upgrade.rb @@ -46,6 +46,8 @@ module Mastodon::CLI upgrade_storage_s3(progress, attachment, style) when :fog upgrade_storage_fog(progress, attachment, style) + when :azure + upgrade_storage_azure(progress, attachment, style) when :filesystem upgrade_storage_filesystem(progress, attachment, style) end @@ -105,6 +107,11 @@ module Mastodon::CLI exit(1) end + def upgrade_storage_azure(_progress, _attachment, _style) + say('The azure storage driver is not supported for this operation at this time', :red) + exit(1) + end + def upgrade_storage_filesystem(progress, attachment, style) previous_storage_schema_version = attachment.storage_schema_version previous_path = attachment.path(style)