scripts/search-index
changeset 100 147be2910b02
parent 99 8719ac564b22
child 101 f5f53cc0ce16
--- a/scripts/search-index	Wed Feb 11 03:46:59 2009 +0200
+++ b/scripts/search-index	Wed Feb 11 03:52:14 2009 +0200
@@ -282,9 +282,12 @@
         # path to our state file
         statefile_path = os.path.join(options.autoload_state_path, 'chan-%s' % channel.id)
         statefile_tmppath = statefile_path + '.tmp'
+
+        # does it exist?
+        have_tmpfile = os.path.exists(statefile_tmppath)
         
         # do we have a tempfile from a previous crash?
-        if os.path.exists(statefile_tmppath) :
+        if have_tmpfile and not options.ignore_resume :
             # first, open it...
             statefile_tmp = open(statefile_tmppath, 'r+')
 
@@ -295,18 +298,25 @@
             after_str = statefile_tmp.read().rstrip()
 
             if after_str :
-                # XXX: one day backwards
+                # parse timestamp
                 after = utils.from_utc_timestamp(int(after_str))
 
+                # one day backwards
+                after = after.replace(day=after.day - 1)
+
                 if not options.quiet :
                     print "\tContinuing earlier progress: after=%s" % after
 
             else :
                 # ignore
                 if not options.quiet :
-                    print "\tIgnoring empty temporary statefile"
+                    print "\t[WARN] Ignoring empty temporary statefile"
 
         else :
+            # warn about old tmpfile that was ignored
+            if have_tmpfile and not options.quiet :
+                print "\t[WARN] Ignoring old tmpfile state"
+
             # open new tempfile
             statefile_tmp = open(statefile_tmppath, 'w')
             
@@ -330,7 +340,7 @@
                 print "\tLast load time was %s" % mtime
 
             elif not options.quiet :
-                print "\tN previous load state!"
+                print "\t[WARN] No previous load state! Loading full logs"
  
         # only after some specific date?
         if options.after :
@@ -439,6 +449,7 @@
     parser.add_option(      "--create",         dest="create",          help="Create index database",               action="store_true" )
     parser.add_option(      "--skip-missing",   dest="skip_missing",    help="Skip missing logfiles",               action="store_true" )
     parser.add_option(      "--reload",         dest="reload",          help="Force reload lines",                  action="store_true" )
+    parser.add_option(      "--ignore-resume",  dest="ignore_resume",   help="Do not try and resume interrupted autoload",  action="store_true" )
     parser.add_option(      "--quiet",          dest="quiet",           help="Supress status messages",             action="store_true" )
 
     # parse