Index: /trunk/Ohana/src/relphot/src/reload_catalogs.c
===================================================================
--- /trunk/Ohana/src/relphot/src/reload_catalogs.c	(revision 7401)
+++ /trunk/Ohana/src/relphot/src/reload_catalogs.c	(revision 7402)
@@ -4,4 +4,6 @@
 
   int i;
+  int status;
+  struct stat filestat;
   Catalog catalog;
 
@@ -11,19 +13,25 @@
   for (i = 0; i < skylist[0].Nregions; i++) {
     catalog.filename = skylist[0].filename[i];
+
+    // XXX only update existing db tables
+    status = stat (catalog.filename, &filestat);
+    if ((status == -1) && (errno == ENOENT)) {
+      if (VERBOSE) fprintf (stderr, "no file %s, skipping\n", catalog.filename);
+      continue;
+    }
     switch (lock_catalog (&catalog, LCK_XCLD)) {
-    case 0:
-      fprintf (stderr, "ERROR: can't lock file %s\n", catalog.filename);
-      exit (1);
-    case 1:
-      gcatalog (&catalog, TRUE); /* load from disk */
-      break;
-    case 2:
-      if (VERBOSE) fprintf (stderr, "no data in %s, skipping\n", catalog.filename);
-      unlock_catalog (&catalog);
-      continue;
-      break;
-    default:
-      fprintf (stderr, "weird lock_catalog exit state\n");
-      exit (1);
+      case 0: // file cannot be locked
+	fprintf (stderr, "ERROR: can't lock file %s\n", catalog.filename);
+	exit (1);
+      case 1: // file is now locked
+	gcatalog (&catalog, TRUE); /* load from disk */
+	break;
+      case 2: // file is empty
+	if (VERBOSE) fprintf (stderr, "no data in file %s, skipping\n", catalog.filename);
+	unlock_catalog (&catalog);
+	continue;
+      default:
+	fprintf (stderr, "weird lock_catalog exit state %s\n", catalog.filename);
+	exit (1);
     }
     initImageBins  (&catalog, 1);
