X-Git-Url: https://git.openstreetmap.org/rails.git/blobdiff_plain/4377e2bd55bd6bed320b7c3595087d4317b1c9bc..1d09cfcb18d589ea494bf5223f2eb9e0a773d7c6:/app/models/trace.rb diff --git a/app/models/trace.rb b/app/models/trace.rb index af2c0af3b..9d710d1ce 100644 --- a/app/models/trace.rb +++ b/app/models/trace.rb @@ -43,12 +43,7 @@ class Trace < ActiveRecord::Base validates :timestamp, :presence => true validates :visibility, :inclusion => %w[private public trackable identifiable] - def destroy - super - FileUtils.rm_f(trace_name) - FileUtils.rm_f(icon_picture_name) - FileUtils.rm_f(large_picture_name) - end + after_destroy :remove_files def tagstring tags.collect(&:tag).join(", ") @@ -280,7 +275,7 @@ class Trace < ActiveRecord::Base def import logger.info("GPX Import importing #{name} (#{id}) from #{user.email}") - gpx = ::GPX::File.new(xml_file) + gpx = ::GPX::File.new(trace_name) f_lat = 0 f_lon = 0 @@ -343,4 +338,12 @@ class Trace < ActiveRecord::Base gpx end + + private + + def remove_files + FileUtils.rm_f(trace_name) + FileUtils.rm_f(icon_picture_name) + FileUtils.rm_f(large_picture_name) + end end