jam-cloud/app/controllers/artifacts_controller.rb

44 lines
1.1 KiB
Ruby

class ArtifactsController < ApplicationController
def versioncheck
# the reported client version
client_version = params[:ver]
# the name of the client
product = params[:product]
# the os (Win32/MacOSX/Unix)
os = params[:os]
product = "#{product}/#{os}"
logger.debug "version check from #{product} with version #{client_version}"
if !client_version.nil? && client_version.start_with?("Compiled")
render :text => "You have a developer version. Upgrades are manual."
return
end
unless ArtifactUpdate::PRODUCTS.include? product
render :text => "Unknown product type"
return
end
@artifact = ArtifactUpdate.find_by_product_and_environment(product, ArtifactUpdate::DEFAULT_ENVIRONMENT)
if @artifact.nil?
logger.error "no product was found for #{product} and environment: #{ArtifactUpdate::DEFAULT_ENVIRONMENT}"
render :text => "No product available"
return
elsif @artifact.version == client_version
render :text => "You have the latest version."
return
else
render :layout => false
end
end
end