Add matching storage manager
This commit is contained in:
@@ -72,7 +72,8 @@ class StorageManager
|
||||
origin
|
||||
end
|
||||
|
||||
def file_path(md5, file_ext, type)
|
||||
def file_path(post_or_md5, file_ext, type)
|
||||
md5 = post_or_md5.is_a?(String) ? post_or_md5 : post_or_md5.md5
|
||||
subdir = subdir_for(md5)
|
||||
file = file_name(md5, file_ext, type)
|
||||
|
||||
|
||||
@@ -5,10 +5,6 @@ syntax. Matches are executed in order of appearance so the first
|
||||
matching manager is returned. You should always add at least one
|
||||
manager with no constraints as a default case.
|
||||
|
||||
This does not derive from StorageManager so only `open_file`,
|
||||
`delete_file`, `store_file`, `file_url`, and `file_path` are
|
||||
implemented.
|
||||
|
||||
### Example
|
||||
|
||||
StorageManager::Match.new do |matcher|
|
||||
@@ -35,7 +31,7 @@ implemented.
|
||||
|
||||
=end
|
||||
|
||||
class StorageManager::Match
|
||||
class StorageManager::Match < StorageManager
|
||||
def initialize
|
||||
@managers = []
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ require 'mail'
|
||||
|
||||
class UploadErrorChecker
|
||||
def check!
|
||||
uploads = Upload.where("status like 'error%' and status not like 'error: Upload::Error - Post with MD5%' and status not like 'error: RuntimeError - duplicate%' and created_at >= ?", 1.hour.ago)
|
||||
uploads = Upload.where("status like 'error%' and status not like 'error: Upload::Error - Post with MD5%' and status not like 'error: RuntimeError - duplicate%' and status not like 'error: ActiveRecord::RecordInvalid - Validation failed: Md5 has already been taken' and created_at >= ?", 1.hour.ago)
|
||||
if uploads.size > 5
|
||||
mail = Mail.new do
|
||||
from Danbooru.config.contact_email
|
||||
|
||||
@@ -162,15 +162,15 @@ class Post < ApplicationRecord
|
||||
end
|
||||
|
||||
def file_path
|
||||
storage_manager.file_path(md5, file_ext, :original)
|
||||
storage_manager.file_path(self, file_ext, :original)
|
||||
end
|
||||
|
||||
def large_file_path
|
||||
storage_manager.file_path(md5, file_ext, :large)
|
||||
storage_manager.file_path(self, file_ext, :large)
|
||||
end
|
||||
|
||||
def preview_file_path
|
||||
storage_manager.file_path(md5, file_ext, :preview)
|
||||
storage_manager.file_path(self, file_ext, :preview)
|
||||
end
|
||||
|
||||
def crop_file_url
|
||||
|
||||
Reference in New Issue
Block a user