IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 7402


Ignore:
Timestamp:
Jun 7, 2006, 8:36:22 AM (20 years ago)
Author:
eugene
Message:

fix to allow relphot to cleanly handle empty/missing catalogs

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Ohana/src/relphot/src/reload_catalogs.c

    r7080 r7402  
    44
    55  int i;
     6  int status;
     7  struct stat filestat;
    68  Catalog catalog;
    79
     
    1113  for (i = 0; i < skylist[0].Nregions; i++) {
    1214    catalog.filename = skylist[0].filename[i];
     15
     16    // XXX only update existing db tables
     17    status = stat (catalog.filename, &filestat);
     18    if ((status == -1) && (errno == ENOENT)) {
     19      if (VERBOSE) fprintf (stderr, "no file %s, skipping\n", catalog.filename);
     20      continue;
     21    }
    1322    switch (lock_catalog (&catalog, LCK_XCLD)) {
    14     case 0:
    15       fprintf (stderr, "ERROR: can't lock file %s\n", catalog.filename);
    16       exit (1);
    17     case 1:
    18       gcatalog (&catalog, TRUE); /* load from disk */
    19       break;
    20     case 2:
    21       if (VERBOSE) fprintf (stderr, "no data in %s, skipping\n", catalog.filename);
    22       unlock_catalog (&catalog);
    23       continue;
    24       break;
    25     default:
    26       fprintf (stderr, "weird lock_catalog exit state\n");
    27       exit (1);
     23      case 0: // file cannot be locked
     24        fprintf (stderr, "ERROR: can't lock file %s\n", catalog.filename);
     25        exit (1);
     26      case 1: // file is now locked
     27        gcatalog (&catalog, TRUE); /* load from disk */
     28        break;
     29      case 2: // file is empty
     30        if (VERBOSE) fprintf (stderr, "no data in file %s, skipping\n", catalog.filename);
     31        unlock_catalog (&catalog);
     32        continue;
     33      default:
     34        fprintf (stderr, "weird lock_catalog exit state %s\n", catalog.filename);
     35        exit (1);
    2836    }
    2937    initImageBins  (&catalog, 1);
Note: See TracChangeset for help on using the changeset viewer.