diff --git a/app/controllers/private_controller.rb b/app/controllers/private_controller.rb index 36a7a785..bb4d782d 100644 --- a/app/controllers/private_controller.rb +++ b/app/controllers/private_controller.rb @@ -19,11 +19,9 @@ class PrivateController < ApplicationController return end - if deploy_private && File.exist?(path) - send_file path, disposition: 'inline' - else - head :not_found - end + raise PageNotFound if deploy_private && File.exist?(path) + + send_file path, disposition: 'inline' end private @@ -47,15 +45,9 @@ class PrivateController < ApplicationController # Devuelve la ruta completa del archivo def path - return @path if @path - - @path = Pathname.new(File.join(deploy_private.destination, file)).realpath.to_s - - raise Errno::ENOENT unless @path.starts_with? deploy_private.destination - - @path + @path ||= Pathname.new(File.join(deploy_private.destination, file)).realpath.to_s rescue Errno::ENOENT - not_found_path + site_not_found_path end # Devuelve la ruta del archivo, limpieza copiada desde Jekyll @@ -76,12 +68,6 @@ class PrivateController < ApplicationController end # Devuelve una página 404.html - def not_found_path - return site_not_found_path if File.exist? site_not_found_path - - raise PageNotFound - end - def site_not_found_path @site_not_found_path ||= File.join(deploy_private.destination, '404.html') end