Skip to content

Commit

Permalink
Do not acts_as_file if JOB_DIR is an empty string
Browse files Browse the repository at this point in the history
  • Loading branch information
sonots committed May 23, 2014
1 parent 19a73a7 commit 1c52348
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
2 changes: 1 addition & 1 deletion lib/fluentd_server/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def self.database_url
end

def self.job_dir
ENV.fetch('JOB_DIR', 'jobs')
ENV['JOB_DIR'] == "" ? nil : ENV.fetch('JOB_DIR', 'jobs')
end

def self.log_path
Expand Down
15 changes: 9 additions & 6 deletions lib/fluentd_server/model.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,18 @@ def new?
class Task < ActiveRecord::Base
include Sinatra::Decorator::Decoratable
include FluentdServer::Logger
include ActiveRecord::ActsAsFile
include TaskRunner # task runnable codes are here

def filename
prefix = "#{self.id.to_s.rjust(4, '0')}" if self.id
File.join(FluentdServer::Config.job_dir, "#{prefix}_result.txt") if prefix
end
if FluentdServer::Config.job_dir
include ActiveRecord::ActsAsFile

acts_as_file :body, :filename => self.instance_method(:filename)
def filename
prefix = "#{self.id.to_s.rjust(4, '0')}" if self.id
File.join(FluentdServer::Config.job_dir, "#{prefix}_result.txt") if prefix
end

acts_as_file :body, :filename => self.instance_method(:filename)
end

def new?
self.id.nil?
Expand Down

0 comments on commit 1c52348

Please sign in to comment.