archives: raise exception if not configured.
This commit is contained in:
@@ -29,17 +29,7 @@ private
|
|||||||
|
|
||||||
def check_availabililty
|
def check_availabililty
|
||||||
if !PoolArchive.enabled?
|
if !PoolArchive.enabled?
|
||||||
respond_to do |format|
|
raise NotImplementedError.new("Archive service is not configured. Pool versions are not saved.")
|
||||||
format.html do
|
|
||||||
flash[:notice] = "Archive service is not configured. Pool versions are not saved."
|
|
||||||
redirect_to :back
|
|
||||||
end
|
|
||||||
format.json do
|
|
||||||
render json: {success: false, reason: "Archive service is not configured"}.to_json, status: 501
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
return false
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
class PostVersionsController < ApplicationController
|
class PostVersionsController < ApplicationController
|
||||||
before_filter :member_only
|
before_filter :member_only
|
||||||
|
before_filter :check_availabililty
|
||||||
respond_to :html, :xml, :json
|
respond_to :html, :xml, :json
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@@ -25,4 +26,12 @@ class PostVersionsController < ApplicationController
|
|||||||
format.js
|
format.js
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def check_availabililty
|
||||||
|
if !PostArchive.enabled?
|
||||||
|
raise NotImplementedError.new("Archive service is not configured. Post versions are not saved.")
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ class PoolArchive < ActiveRecord::Base
|
|||||||
def self.queue(pool)
|
def self.queue(pool)
|
||||||
# queue updates to sqs so that if archives goes down for whatever reason it won't
|
# queue updates to sqs so that if archives goes down for whatever reason it won't
|
||||||
# block pool updates
|
# block pool updates
|
||||||
raise "Archive service is not configured" if !enabled?
|
raise NotImplementedError.new("Archive service is not configured.") if !enabled?
|
||||||
|
|
||||||
json = {
|
json = {
|
||||||
pool_id: pool.id,
|
pool_id: pool.id,
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ class PoolVersion < ActiveRecord::Base
|
|||||||
extend SearchMethods
|
extend SearchMethods
|
||||||
|
|
||||||
def self.export_to_archives(starting_version_id = 0)
|
def self.export_to_archives(starting_version_id = 0)
|
||||||
raise "SQS URL not setup" if Danbooru.config.aws_sqs_archives_url.nil?
|
raise NotImplementedError.new("SQS URL not setup") if Danbooru.config.aws_sqs_archives_url.nil?
|
||||||
|
|
||||||
credentials = Aws::Credentials.new(
|
credentials = Aws::Credentials.new(
|
||||||
Danbooru.config.aws_access_key_id,
|
Danbooru.config.aws_access_key_id,
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ class PostArchive < ActiveRecord::Base
|
|||||||
def queue(post)
|
def queue(post)
|
||||||
# queue updates to sqs so that if archives goes down for whatever reason it won't
|
# queue updates to sqs so that if archives goes down for whatever reason it won't
|
||||||
# block post updates
|
# block post updates
|
||||||
raise "Archive service is not configured" if !enabled?
|
raise NotImplementedError.new("Archive service is not configured") if !enabled?
|
||||||
|
|
||||||
json = {
|
json = {
|
||||||
"post_id" => post.id,
|
"post_id" => post.id,
|
||||||
|
|||||||
Reference in New Issue
Block a user