IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Sep 9, 2010, 1:22:02 PM (16 years ago)
Author:
bills
Message:

in magicdstool -advancerun move the transactoin inside the loop so that if one
run has a problem it doesn't rollback other runs that worked.
Get magicked status of the run. If it is already set don't try and set it again.

File:
1 edited

Legend:

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

    r28936 r29136  
    950950        return true;
    951951    }
    952     if (!psDBTransaction(config->dbh)) {
    953         psError(PS_ERR_UNKNOWN, false, "database error");
    954         return false;
    955     }
    956952    for (long i = 0; i < psArrayLength(output); i++) {
    957953        psMetadata *row = output->data[i];
    958954
    959955        psS64 magic_ds_id = psMetadataLookupS64(NULL, row, "magic_ds_id");
     956        psS64 magicked =  psMetadataLookupS64(NULL, row, "magicked");
     957        if (!psDBTransaction(config->dbh)) {
     958            psError(PS_ERR_UNKNOWN, false, "database error");
     959            return false;
     960        }
    960961
    961962        // if re_place, set stageRun.magicked
    962963        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");
     964        if (setmagicked) {
     965            if (magicked <= 0) {
     966                if (!setRunMagicked(config, magic_ds_id)) {
     967                    psError(PS_ERR_UNKNOWN, false, "failed to change stageRun.magicked for magic_ds_id: %" PRId64,
     968                        magic_ds_id);
     969                    if (!psDBRollback(config->dbh)) {
     970                        psError(PS_ERR_UNKNOWN, false, "database error");
     971                    }
     972                    return false;
     973                }
     974            } else {
     975                fprintf(stderr, "run is already marked as destreaked for magic_ds_id %" PRId64 "\n", magic_ds_id);
    968976            }
    969             return false;
    970977        }
    971978
     
    980987            return false;
    981988        }
    982     }
    983     if (!psDBCommit(config->dbh)) {
    984         psError(PS_ERR_UNKNOWN, false, "database error");
    985         return false;
     989        if (!psDBCommit(config->dbh)) {
     990            psError(PS_ERR_UNKNOWN, false, "database error");
     991            return false;
     992        }
    986993    }
    987994
Note: See TracChangeset for help on using the changeset viewer.