IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jul 24, 2006, 5:50:02 PM (20 years ago)
Author:
jhoblitt
Message:

fix pzsearchFlushPendingExp() so that newExp entries are created
change copydoneMode() so that it calls psDBRollback() when appropriate

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ippTools/src/pztool.c

    r7970 r7972  
    136136    for (long i = 0; i < pending->n; i++) {
    137137        pzPendingImfileRow *pendingImfile = pending->data[i];
    138         newImfileRow *newImfile = newImfileRowAlloc(
     138
     139        if (!newImfileInsert(
     140            config->dbh,
    139141            pendingImfile->exp_id,
    140142            pendingImfile->class,
    141143            pendingImfile->class_id,
    142144            // XXX get this from the CLI
    143             pendingImfile->uri
    144         );
    145 
    146         if (!newImfileInsertObject(config->dbh, newImfile)) {
     145            pendingImfile->uri)
     146        ) {
    147147            psError(PS_ERR_UNKNOWN, false, "dbh access failed");
    148             psFree(newImfile);
    149             return false;
    150         }
    151 
    152         psFree(newImfile);
    153     }
    154 
    155     if (pzPendingImfileDeleteRowObjects(config->dbh, pending, MAX_ROWS)
    156         < 0) {
     148            psFree(pending);
     149            goto ROLLBACK;
     150        }
     151    }
     152
     153    if (pzPendingImfileDeleteRowObjects(config->dbh, pending, MAX_ROWS) < 0) {
    157154        psError(PS_ERR_UNKNOWN, false, "dbh access failed");
    158155        psFree(pending);
    159         return false;
     156        goto ROLLBACK;
    160157    }
    161158    psFree(pending);
     
    164161    if (!pzsearchFlushPendingExp(config)) {
    165162        psError(PS_ERR_UNKNOWN, false, "pzsearchFlushPendingExp() failed");
    166         return false;
     163        goto ROLLBACK;
    167164    }
    168165
     
    170167    if (!psDBCommit(config->dbh)) {
    171168        psError(PS_ERR_UNKNOWN, false, "database error");
    172         return false;
    173     }
    174 
    175     return true;
     169        // XXX is this the right thing to do after a commit failure?
     170        goto ROLLBACK;
     171    }
     172
     173    return true;
     174
     175ROLLBACK:
     176    // rollback
     177    if (!psDBRollback(config->dbh)) {
     178        psError(PS_ERR_UNKNOWN, false, "database error");
     179    }
     180
     181    return false;
    176182}
    177183
     
    240246
    241247        if (!pendingImfiles) {
    242             // exp has no coresponding imfiles
     248            // exp has no coresponding imfiles so we need to remove it from
     249            // pzPendingExp and add it to newExp
     250
     251            if (!newExpInsert(
     252                    config->dbh,
     253                    pendingExp->exp_id,
     254                    pendingExp->camera,
     255                    pendingExp->telescope,
     256                    pendingExp->exp_type,
     257                    pendingExp->imfiles)
     258            ) {
     259                psError(PS_ERR_UNKNOWN, false, "dbh access failed");
     260                psFree(pending);
     261                return false;
     262            }
    243263
    244264            psArray *nukeMe = psArrayAlloc(1);
     
    252272            }
    253273        }
    254     }
    255 
    256     return true;
    257 }
     274
     275        psFree(pendingImfiles);
     276    }
     277
     278    return true;
     279}
Note: See TracChangeset for help on using the changeset viewer.