From 5f3ce1210a3bb6903c9931e70baea4d598df4a0d Mon Sep 17 00:00:00 2001 From: Matchu Date: Thu, 12 Oct 2023 22:40:36 -0700 Subject: [PATCH] Stop saving local copies of SWFs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit I think we used this for both conversion to image, and also for CORS stuff when rendering Flash-based previews… let's trash it, I don't want to be growing our hard drive with files I don't think we use anymore! If I'm wrong and it turns out we do use them for something, then like. hey I'm sure we'll find out soon enough, and it's very recoverable operation. --- app/models/swf_asset.rb | 51 ----------------------------------- public/swfs/outfit/.gitignore | 2 -- 2 files changed, 53 deletions(-) delete mode 100644 public/swfs/outfit/.gitignore diff --git a/app/models/swf_asset.rb b/app/models/swf_asset.rb index b70686eb..75e8ee9b 100644 --- a/app/models/swf_asset.rb +++ b/app/models/swf_asset.rb @@ -4,9 +4,6 @@ require 'uri' class SwfAsset < ApplicationRecord # We use the `type` column to mean something other than what Rails means! self.inheritance_column = nil - - PUBLIC_ASSET_DIR = File.join('swfs', 'outfit') - LOCAL_ASSET_DIR = Rails.root.join('public', PUBLIC_ASSET_DIR) IMAGE_SIZES = { :small => [150, 150], @@ -19,10 +16,6 @@ class SwfAsset < ApplicationRecord scope :includes_depth, -> { includes(:zone) } - def local_swf_path - LOCAL_ASSET_DIR.join(local_path_within_outfit_swfs) - end - def swf_image_dir @swf_image_dir ||= Rails.root.join('tmp', 'asset_images_before_upload', self.id.to_s) end @@ -100,10 +93,6 @@ class SwfAsset < ApplicationRecord self.body_id = new_body_id end - def local_url - '/' + File.join(PUBLIC_ASSET_DIR, local_path_within_outfit_swfs) - end - def as_json(options={}) json = { :id => remote_id, @@ -119,11 +108,6 @@ class SwfAsset < ApplicationRecord :has_image => true, :images => images } - if options[:for] == 'wardrobe' - json[:local_path] = local_url - else - json[:local_url] = local_url - end json[:parent_id] = options[:parent_id] if options[:parent_id] json end @@ -179,31 +163,6 @@ class SwfAsset < ApplicationRecord )) end - before_create do - uri = URI.parse(url) - begin - http = Net::HTTP.new(uri.host, uri.port) - http.use_ssl = true if uri.instance_of? URI::HTTPS - response = http.get(uri.request_uri) - rescue Exception => e - raise DownloadError, e.message - end - if response.is_a? Net::HTTPSuccess - new_local_path = File.join(LOCAL_ASSET_DIR, local_path_within_outfit_swfs) - new_local_dir = File.dirname new_local_path - FileUtils.mkdir_p new_local_dir - File.binwrite(new_local_path, response.body) - else - begin - response.error! - rescue Exception => e - raise DownloadError, "Error loading SWF at #{url}: #{e.message}" - else - raise DownloadError, "Error loading SWF at #{url}. Response: #{response.inspect}" - end - end - end - before_save do # If an asset body ID changes, that means more than one body ID has been # linked to it, meaning that it's probably wearable by all bodies. @@ -211,14 +170,4 @@ class SwfAsset < ApplicationRecord end class DownloadError < Exception;end - - private - - def local_path_within_outfit_swfs - uri = URI.parse(url) - pieces = uri.path.split('/') - relevant_pieces = pieces[4..7] - relevant_pieces.unshift pieces[2] - File.join(relevant_pieces) - end end diff --git a/public/swfs/outfit/.gitignore b/public/swfs/outfit/.gitignore deleted file mode 100644 index d6b7ef32..00000000 --- a/public/swfs/outfit/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -* -!.gitignore