From d82dd31380980cc204eb7da29b2f049ff961f472 Mon Sep 17 00:00:00 2001
From: Hal Simpson <hasimpson@usgs.gov>
Date: Mon, 25 Jan 2016 13:52:40 -0700
Subject: [PATCH] Added code to limit crawling back during update.

---
 geomagio/Controller.py | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/geomagio/Controller.py b/geomagio/Controller.py
index 9d21f228..494a96c2 100644
--- a/geomagio/Controller.py
+++ b/geomagio/Controller.py
@@ -217,7 +217,8 @@ class Controller(object):
                     stream=input_timeseries):
                 continue
             # check for fillable gap at start
-            if output_gap[0] == options.starttime:
+            if options.update_count < options.update_max_iterations and \
+                    output_gap[0] == options.starttime:
                 # found fillable gap at start, recurse to previous interval
                 interval = options.endtime - options.starttime
                 options.starttime = options.starttime - interval - delta
@@ -384,6 +385,7 @@ def main(args):
     controller = Controller(inputfactory, outputfactory, algorithm)
 
     if args.update:
+        args.update_count = 0
         controller.run_as_update(args)
     else:
         controller.run(args)
@@ -451,6 +453,10 @@ def parse_args(args):
             action='store_true',
             default=False,
             help='Used to update data')
+    parser.add_argument('--update-max-iterations',
+            type=int,
+            help='Maximum iterations update will attempt.'
+            )
     parser.add_argument('--input-edge-port',
             type=int,
             default=2060,
-- 
GitLab