1423 |
1423 |
1424 // ---------------------------------------------------------------------------- |
1424 // ---------------------------------------------------------------------------- |
1425 // Verifies that the volume ID of the database matches the drive |
1425 // Verifies that the volume ID of the database matches the drive |
1426 // ---------------------------------------------------------------------------- |
1426 // ---------------------------------------------------------------------------- |
1427 // |
1427 // |
|
1428 void CMPXPodcastDbHandler::VerifyVolumeIdL( TInt aDrive ) |
|
1429 { |
|
1430 MPX_DEBUG1("CMPXPodcastDbHandler::VerifyVolumeIdL <--"); |
|
1431 |
|
1432 if( iDbManager->IsOpen(aDrive) ) |
|
1433 { |
|
1434 TVolumeInfo volInfo; |
|
1435 iFs.Volume(volInfo, aDrive ); |
|
1436 TUint curId(volInfo.iUniqueID); |
|
1437 |
|
1438 TInt volId = iDbAuxiliary->IdL( aDrive ); |
|
1439 |
|
1440 // New database, no volume id set, mask out top bit because this is an uint |
|
1441 // |
|
1442 MPX_DEBUG3("CMPXPodcastDbHandler::VerifyVolumeIdL drive:%i db:%i", curId, volId); |
|
1443 if( volId == 0 && (curId&0x7FFFFFFF) ) |
|
1444 { |
|
1445 MPX_DEBUG1("CMPXPodcastDbHandler::VerifyVolumeIdL -- New ID"); |
|
1446 BeginTransactionL(); |
|
1447 TRAPD( err, iDbAuxiliary->SetIdL( aDrive, curId&0x7FFFFFFF ) ); |
|
1448 EndTransactionL( err ); |
|
1449 |
|
1450 // KSqlDbCorrupted indicates DB corrupted, need to recreate. |
|
1451 if ( err == KSqlDbCorrupted ) |
|
1452 { |
|
1453 MPX_DEBUG1("CMPXPodcastDbHandler::VerifyVolumeIdL -- Corrupted DB"); |
|
1454 iDbManager->RecreateDatabaseL( aDrive ); |
|
1455 BeginTransactionL(); |
|
1456 TRAPD( err, iDbAuxiliary->SetDBCorruptedL( ETrue ) ); |
|
1457 EndTransactionL( err ); |
|
1458 } |
|
1459 } |
|
1460 // Unmatched volume id, mark db as corrupt |
|
1461 // |
|
1462 else if ( (curId&0x7FFFFFFF) != (volId&0x7FFFFFFFF) ) |
|
1463 { |
|
1464 MPX_DEBUG1("CMPXPodcastDbHandler::VerifyVolumeIdL -- ID match FAILED"); |
|
1465 iDbManager->RecreateDatabaseL( aDrive ); |
|
1466 BeginTransactionL(); |
|
1467 TRAPD( err, iDbAuxiliary->SetDBCorruptedL( ETrue ) ); |
|
1468 EndTransactionL( err ); |
|
1469 } |
|
1470 } |
|
1471 MPX_DEBUG1("CMPXPodcastDbHandler::VerifyVolumeIdL -->"); |
|
1472 } |
|
1473 |
|
1474 |
|
1475 // ---------------------------------------------------------------------------- |
|
1476 // Verifies that the volume ID of the database matches the drive |
|
1477 // ---------------------------------------------------------------------------- |
|
1478 // |
1428 void CMPXPodcastDbHandler::VerifyVolumeIdL() |
1479 void CMPXPodcastDbHandler::VerifyVolumeIdL() |
1429 { |
1480 { |
1430 MPX_DEBUG1("CMPXPodcastDbHandler::VerifyVolumeIdL <--"); |
1481 MPX_DEBUG1("CMPXPodcastDbHandler::VerifyVolumeIdL <--"); |
1431 |
|
1432 TInt count( iDbDrives.Count() ); |
1482 TInt count( iDbDrives.Count() ); |
1433 for( TInt i=0; i<count; ++i ) |
1483 for( TInt i=0; i<count; ++i ) |
1434 { |
1484 { |
1435 if( iDbManager->IsOpen(iDbDrives[i]) ) |
1485 VerifyVolumeIdL(iDbDrives[i]); |
1436 { |
|
1437 TVolumeInfo volInfo; |
|
1438 iFs.Volume(volInfo, iDbDrives[i] ); |
|
1439 TUint curId(volInfo.iUniqueID); |
|
1440 |
|
1441 TInt volId = iDbAuxiliary->IdL( iDbDrives[i] ); |
|
1442 |
|
1443 // New database, no volume id set, mask out top bit because this is an uint |
|
1444 // |
|
1445 MPX_DEBUG3("CMPXPodcastDbHandler::VerifyVolumeIdL drive:%i db:%i", curId, volId); |
|
1446 if( volId == 0 ) |
|
1447 { |
|
1448 MPX_DEBUG1("CMPXPodcastDbHandler::VerifyVolumeIdL -- New ID"); |
|
1449 BeginTransactionL(); |
|
1450 TRAPD( err, iDbAuxiliary->SetIdL( iDbDrives[i], curId&0x7FFFFFFF ) ); |
|
1451 EndTransactionL( err ); |
|
1452 |
|
1453 // KSqlDbCorrupted indicates DB corrupted, need to recreate. |
|
1454 if ( err == KSqlDbCorrupted ) |
|
1455 { |
|
1456 MPX_DEBUG1("CMPXPodcastDbHandler::VerifyVolumeIdL -- Corrupted DB"); |
|
1457 iDbManager->RecreateDatabaseL(iDbDrives[i]); |
|
1458 BeginTransactionL(); |
|
1459 TRAPD(err, iDbAuxiliary->SetDBCorruptedL( ETrue ) ); |
|
1460 EndTransactionL( err ); |
|
1461 } |
|
1462 } |
|
1463 // Unmatched volume id, mark db as corrupt |
|
1464 // |
|
1465 else if ( (curId&0x7FFFFFFF) != (volId&0x7FFFFFFFF) ) |
|
1466 { |
|
1467 MPX_DEBUG1("CMPXPodcastDbHandler::VerifyVolumeIdL -- ID match FAILED"); |
|
1468 iDbManager->RecreateDatabaseL(iDbDrives[i]); |
|
1469 BeginTransactionL(); |
|
1470 TRAPD(err, iDbAuxiliary->SetDBCorruptedL( ETrue ) ); |
|
1471 EndTransactionL( err ); |
|
1472 } |
|
1473 } |
|
1474 } |
1486 } |
1475 MPX_DEBUG1("CMPXPodcastDbHandler::VerifyVolumeIdL -->"); |
1487 MPX_DEBUG1("CMPXPodcastDbHandler::VerifyVolumeIdL -->"); |
1476 } |
1488 } |
1477 |
1489 |
1478 // ---------------------------------------------------------------------------- |
1490 // ---------------------------------------------------------------------------- |