IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Oct 21, 2010, 2:45:13 PM (16 years ago)
Author:
eugene
Message:

merge changes from trunk

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20100823/ippTools/src/magicdstool.c

    r28936 r29515  
    637637    psFree(where);
    638638
     639    psStringAppend(&query, "\nORDER BY priority DESC, magic_ds_id");
     640
    639641    // treat limit == 0 as "no limit"
    640642    if (limit) {
     
    933935    }
    934936
     937    // treat limit == 0 as "no limit"
     938    if (limit) {
     939        psString limitString = psDBGenerateLimitSQL(limit);
     940        psStringAppend(&query, " %s", limitString);
     941        psFree(limitString);
     942    }
     943
    935944    if (!p_psDBRunQuery(config->dbh, query)) {
    936945        psError(PS_ERR_UNKNOWN, false, "database error");
     
    950959        return true;
    951960    }
    952     if (!psDBTransaction(config->dbh)) {
    953         psError(PS_ERR_UNKNOWN, false, "database error");
    954         return false;
    955     }
    956961    for (long i = 0; i < psArrayLength(output); i++) {
    957962        psMetadata *row = output->data[i];
    958963
    959964        psS64 magic_ds_id = psMetadataLookupS64(NULL, row, "magic_ds_id");
     965        psS64 magicked =  psMetadataLookupS64(NULL, row, "magicked");
     966        if (!psDBTransaction(config->dbh)) {
     967            psError(PS_ERR_UNKNOWN, false, "database error");
     968            return false;
     969        }
    960970
    961971        // if re_place, set stageRun.magicked
    962972        bool setmagicked = psMetadataLookupBool(NULL, row, "re_place");
    963         if (setmagicked && !setRunMagicked(config, magic_ds_id)) {
    964             psError(PS_ERR_UNKNOWN, false, "failed to change stageRun.magicked for magic_ds_id: %" PRId64,
    965                 magic_ds_id);
    966             if (!psDBRollback(config->dbh)) {
    967                 psError(PS_ERR_UNKNOWN, false, "database error");
     973        if (setmagicked) {
     974            if (magicked <= 0) {
     975                if (!setRunMagicked(config, magic_ds_id)) {
     976                    psError(PS_ERR_UNKNOWN, false, "failed to change stageRun.magicked for magic_ds_id: %" PRId64,
     977                        magic_ds_id);
     978                    if (!psDBRollback(config->dbh)) {
     979                        psError(PS_ERR_UNKNOWN, false, "database error");
     980                    }
     981                    return false;
     982                }
     983            } else {
     984                fprintf(stderr, "run is already marked as destreaked for magic_ds_id %" PRId64 "\n", magic_ds_id);
    968985            }
    969             return false;
    970986        }
    971987
     
    980996            return false;
    981997        }
    982     }
    983     if (!psDBCommit(config->dbh)) {
    984         psError(PS_ERR_UNKNOWN, false, "database error");
    985         return false;
     998        if (!psDBCommit(config->dbh)) {
     999            psError(PS_ERR_UNKNOWN, false, "database error");
     1000            return false;
     1001        }
    9861002    }
    9871003
Note: See TracChangeset for help on using the changeset viewer.