# typed: strict
class Domain::E621::Job::StaticFileJob < Domain::E621::Job::Base
  include Domain::StaticFileJobHelper
  queue_as :static_file

  sig { override.params(args: T::Hash[Symbol, T.untyped]).returns(T.untyped) }
  def perform(args)
    file =
      if file = (args[:file] || args[:post_file])
        T.cast(file, Domain::PostFile)
      elsif (post = args[:post]) && post.is_a?(Domain::Post::E621Post)
        T.must(post.file)
      else
        fatal_error(":file or :post is required")
      end

    logger.push_tags(make_arg_tag(file), make_arg_tag(file.post))
    download_post_file(file)
  end
end
