Changeset 24883 for trunk/ippTools/src/magictool.c
- Timestamp:
- Jul 21, 2009, 2:42:19 PM (17 years ago)
- File:
-
- 1 edited
-
trunk/ippTools/src/magictool.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippTools/src/magictool.c
r24551 r24883 47 47 static bool revertmaskMode(pxConfig *config); 48 48 static bool maskMode(pxConfig *config); 49 static bool censorrunMode(pxConfig *config); 49 50 50 51 static bool setmagicRunState(pxConfig *config, psS64 magic_id, const char *state); … … 85 86 MODECASE(MAGICTOOL_MODE_REVERTMASK, revertmaskMode); 86 87 MODECASE(MAGICTOOL_MODE_MASK, maskMode); 88 MODECASE(MAGICTOOL_MODE_CENSORRUN, censorrunMode); 87 89 default: 88 90 psAbort("invalid option (this should not happen)"); … … 1367 1369 return true; 1368 1370 } 1371 1372 static bool censorStage(pxConfig *config, psString stage, psString whereClause) 1373 { 1374 psString queryFile = NULL; 1375 psStringAppend(&queryFile, "magicdstool_censor_%s.sql", stage); 1376 psString query = pxDataGet(queryFile); 1377 if (!query) { 1378 psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement from %s", queryFile); 1379 psFree(queryFile); 1380 if (!psDBRollback(config->dbh)) { 1381 psError(PS_ERR_UNKNOWN, false, "database error"); 1382 } 1383 return false; 1384 } 1385 psFree(queryFile); 1386 1387 psStringAppend(&query, whereClause); 1388 1389 if (!p_psDBRunQuery(config->dbh, query)) { 1390 psError(PS_ERR_UNKNOWN, false, "database error"); 1391 psFree(query); 1392 if (!psDBRollback(config->dbh)) { 1393 psError(PS_ERR_UNKNOWN, false, "database error"); 1394 } 1395 return false; 1396 } 1397 psFree(query); 1398 1399 return true; 1400 } 1401 1402 static bool censorrunMode(pxConfig *config) 1403 { 1404 PS_ASSERT_PTR_NON_NULL(config, false); 1405 1406 psMetadata *where = psMetadataAlloc(); 1407 1408 // at least one of these required 1409 PXOPT_COPY_S64(config->args, where, "-magic_id", "magic_id", "=="); 1410 PXOPT_COPY_S64(config->args, where, "-exp_id", "exp_id", "=="); 1411 1412 if (!psListLength(where->list)) { 1413 psError(PS_ERR_UNKNOWN, true, "either -exp_id or -magic_id is required"); 1414 psFree(where); 1415 return false; 1416 } 1417 1418 psString query = psStringCopy("UPDATE magicRun SET state = 'censored'"); 1419 1420 psString whereClause = psDBGenerateWhereConditionSQL(where, "magicRun"); 1421 psFree(where); 1422 psStringAppend(&query, " WHERE %s", whereClause); 1423 1424 if (!psDBTransaction(config->dbh)) { 1425 psError(PS_ERR_UNKNOWN, false, "database error"); 1426 return false; 1427 } 1428 1429 if (!p_psDBRunQuery(config->dbh, query)) { 1430 psError(PS_ERR_UNKNOWN, false, "database error"); 1431 psFree(whereClause); 1432 psFree(query); 1433 return false; 1434 } 1435 psFree(query); 1436 1437 // Now queue any destreaked files to be re-verted 1438 1439 // note: on failure censorStage issues the rollback 1440 if (!censorStage(config, "raw", whereClause)) { 1441 psFree(whereClause); 1442 return false; 1443 } 1444 if (!censorStage(config, "chip", whereClause)) { 1445 psFree(whereClause); 1446 return false; 1447 } 1448 if (!censorStage(config, "camera", whereClause)) { 1449 psFree(whereClause); 1450 return false; 1451 } 1452 if (!censorStage(config, "warp", whereClause)) { 1453 psFree(whereClause); 1454 return false; 1455 } 1456 if (!censorStage(config, "diff", whereClause)) { 1457 psFree(whereClause); 1458 return false; 1459 } 1460 1461 psFree(whereClause); 1462 1463 if (!psDBCommit(config->dbh)) { 1464 psError(PS_ERR_UNKNOWN, false, "database error"); 1465 return false; 1466 } 1467 1468 return true; 1469 }
Note:
See TracChangeset
for help on using the changeset viewer.
