]> git.openstreetmap.org Git - rails.git/commitdiff
Merge pull request #4536 from tomhughes/trace-size-limit
authorAndy Allan <git@gravitystorm.co.uk>
Sun, 25 Feb 2024 10:35:20 +0000 (11:35 +0100)
committerGitHub <noreply@github.com>
Sun, 25 Feb 2024 10:35:20 +0000 (11:35 +0100)
Add a limit on the number of points in a GPS trace

1  2 
app/models/trace.rb

diff --combined app/models/trace.rb
index 1e8f25a830757b64f9cfa692d6fcaa6a74fce03b,3ab25ce3098735a6058d1a94d053c8143483bdaa..818cc363b8629595bed5a4d842033f708598f14c
@@@ -202,7 -202,7 +202,7 @@@ class Trace < ApplicationRecor
      logger.info("GPX Import importing #{name} (#{id}) from #{user.email}")
  
      file.open do |file|
-       gpx = GPX::File.new(file.path)
+       gpx = GPX::File.new(file.path, :maximum_points => Settings.max_trace_size)
  
        f_lat = 0
        f_lon = 0
      end
    end
  
 +  def schedule_import
 +    TraceImporterJob.new(self).enqueue(:priority => user.traces.where(:inserted => false).count)
 +  end
 +
 +  def schedule_destruction
 +    TraceDestroyerJob.perform_later(self)
 +  end
 +
    private
  
    def content_type(file)