diff options
Diffstat (limited to 'app/models/fax_document.rb')
-rw-r--r-- | app/models/fax_document.rb | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/app/models/fax_document.rb b/app/models/fax_document.rb index e9bb5f1..5b27965 100644 --- a/app/models/fax_document.rb +++ b/app/models/fax_document.rb @@ -19,6 +19,8 @@ class FaxDocument < ActiveRecord::Base after_save :convert_to_tiff after_create :render_thumbnails + + after_destroy :remove_storage_dir # Scopes scope :inbound, where(:state => 'inbound') @@ -105,9 +107,9 @@ class FaxDocument < ActiveRecord::Base def store_dir if self.try(:inbound) - "/var/opt/gemeinschaft/fax/in/#{self.id}" + "/var/opt/gemeinschaft/fax/in/#{self.id.to_i}" else - "/var/opt/gemeinschaft/fax/out/#{self.id}" + "/var/opt/gemeinschaft/fax/out/#{self.id.to_i}" end end @@ -121,4 +123,10 @@ class FaxDocument < ActiveRecord::Base end end + def remove_storage_dir + if File.directory?(self.store_dir) + FileUtils.rm_rf(self.store_dir) + end + end + end |