summaryrefslogtreecommitdiff
path: root/app/models
diff options
context:
space:
mode:
authorspag <spag@golwen.net>2013-02-19 14:05:11 +0100
committerspag <spag@golwen.net>2013-02-19 14:05:11 +0100
commit22d581aa38ae4e015c654356fb61d110456e69ee (patch)
tree00a87e6dc1ef3c32e5e949af03483dd6b92f7dfc /app/models
parent79f70b1dbf03193809979d832d368a19dadcb94f (diff)
preserve tiff file
Diffstat (limited to 'app/models')
-rw-r--r--app/models/fax_document.rb12
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