IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jul 16, 2007, 6:28:21 PM (19 years ago)
Author:
jhoblitt
Message:

change difftool -addinputskyfile to automatically set the diffRun.state to run after 2 inputskyfiles have been registered

File:
1 edited

Legend:

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

    r14255 r14260  
    4040static bool revertdiffskyfileMode(pxConfig *config);
    4141
    42 static bool setdiffRunState(pxConfig *config, const char *warp_id, const char *state);
     42static bool setdiffRunState(pxConfig *config, const char *diff_id, const char *state);
    4343
    4444# define MODECASE(caseName, func) \
     
    297297    }
    298298
     299    if (!psDBTransaction(config->dbh)) {
     300        psError(PS_ERR_UNKNOWN, false, "database error");
     301        return false;
     302    }
     303
    299304    if (!diffInputSkyfileInsert(config->dbh,
    300305            (psS64)atoll(diff_id),
     
    306311            kind
    307312        )) {
     313        if (!psDBRollback(config->dbh)) {
     314            psError(PS_ERR_UNKNOWN, false, "database error");
     315        }
     316        psError(PS_ERR_UNKNOWN, false, "database error");
     317        return false;
     318    }
     319
     320    if (!p_psDBRunQuery(config->dbh, "SELECT count(diff_id) FROM diffRun JOIN diffInputSkyfile USING(diff_id) WHERE diff_id = %" PRId64, (psS64)atoll(diff_id))) {
     321        if (!psDBRollback(config->dbh)) {
     322            psError(PS_ERR_UNKNOWN, false, "database error");
     323        }
     324        psError(PS_ERR_UNKNOWN, false, "database error");
     325        return false;
     326    }
     327
     328    psArray *output = p_psDBFetchResult(config->dbh);
     329    if (!output) {
     330        if (!psDBRollback(config->dbh)) {
     331            psError(PS_ERR_UNKNOWN, false, "database error");
     332        }
     333        psError(PS_ERR_UNKNOWN, false, "database error");
     334        return false;
     335    }
     336    if (!psArrayLength(output)) {
     337        if (!psDBRollback(config->dbh)) {
     338            psError(PS_ERR_UNKNOWN, false, "database error");
     339        }
     340        psError(PS_ERR_UNKNOWN, false, "diff_id %" PRId64 " not found", (psS64)atoll(diff_id));
     341        psFree(output);
     342        return false;
     343    }
     344
     345    psS32 count = psMetadataLookupS32(&status, output->data[0], "count(diff_id)");
     346
     347    if (count == 2) {
     348        if (!setdiffRunState(config, diff_id, "run")) {
     349            if (!psDBRollback(config->dbh)) {
     350                psError(PS_ERR_UNKNOWN, false, "database error");
     351            }
     352            psError(PS_ERR_UNKNOWN, false, "database error");
     353            return false;
     354        }
     355    }
     356
     357    // point of no return
     358    if (!psDBCommit(config->dbh)) {
    308359        psError(PS_ERR_UNKNOWN, false, "database error");
    309360        return false;
Note: See TracChangeset for help on using the changeset viewer.