2669 |
2669 |
2670 // ---------------------------------------------------------------------------- |
2670 // ---------------------------------------------------------------------------- |
2671 // Verifies that the volume ID of the database matches the drive |
2671 // Verifies that the volume ID of the database matches the drive |
2672 // ---------------------------------------------------------------------------- |
2672 // ---------------------------------------------------------------------------- |
2673 // |
2673 // |
2674 void CMPXDbHandler::VerifyVolumeIdL() |
2674 void CMPXDbHandler::VerifyVolumeIdL( TInt aDrive ) |
2675 { |
2675 { |
2676 MPX_DEBUG1("CMPXDbHandler::VerifyVolumeIdL <--"); |
2676 MPX_DEBUG1("CMPXDbHandler::VerifyVolumeIdL <--"); |
2677 |
2677 if( iDbManager->IsOpen( aDrive ) ) |
2678 TInt count( iDbDrives.Count() ); |
|
2679 for( TInt i=0; i<count; ++i ) |
|
2680 { |
|
2681 if( iDbManager->IsOpen( iDbDrives[i] ) ) |
|
2682 { |
2678 { |
2683 TVolumeInfo volInfo; |
2679 TVolumeInfo volInfo; |
2684 iFs.Volume(volInfo, iDbDrives[i] ); |
2680 iFs.Volume(volInfo, aDrive ); |
2685 TUint curId(volInfo.iUniqueID); |
2681 TUint curId(volInfo.iUniqueID); |
2686 |
2682 |
2687 TInt volId = iDbAuxiliary->IdL( iDbDrives[i] ); |
2683 TInt volId = iDbAuxiliary->IdL( aDrive ); |
2688 |
2684 |
2689 // New database, no volume id set, mask out top bit because this is an uint |
2685 // New database, no volume id set, mask out top bit because this is an uint |
2690 // |
2686 // |
2691 MPX_DEBUG3("CMPXDBHandler::VerifyVolumeIdL drive:%i db:%i", curId, volId); |
2687 MPX_DEBUG3("CMPXDBHandler::VerifyVolumeIdL drive:%i db:%i", curId, volId); |
2692 if( volId == 0 ) |
2688 if( volId == 0 && (curId&0x7FFFFFFF) ) |
2693 { |
2689 { |
2694 MPX_DEBUG1("CMPXDbHandler::VerifyVolumeIdL -- New ID"); |
2690 MPX_DEBUG1("CMPXDbHandler::VerifyVolumeIdL -- New ID"); |
2695 BeginTransactionL(); |
2691 BeginTransactionL(); |
2696 TRAPD( err, iDbAuxiliary->SetIdL( iDbDrives[i], curId&0x7FFFFFFF ) ); |
2692 TRAPD( err, iDbAuxiliary->SetIdL( aDrive, curId&0x7FFFFFFF ) ); |
2697 EndTransactionL( err ); |
2693 EndTransactionL( err ); |
2698 |
2694 |
2699 // KSqlDbCorrupted indicates DB corrupted, need to recreate. |
2695 // KSqlDbCorrupted indicates DB corrupted, need to recreate. |
2700 if ( err == KSqlDbCorrupted ) |
2696 if ( err == KSqlDbCorrupted ) |
2701 { |
2697 { |
2702 MPX_DEBUG1("CMPXPodcastDbHandler::VerifyVolumeIdL -- Corrupted DB"); |
2698 MPX_DEBUG1("CMPXPodcastDbHandler::VerifyVolumeIdL -- Corrupted DB"); |
2703 iDbManager->RecreateDatabaseL(iDbDrives[i]); |
2699 iDbManager->RecreateDatabaseL(aDrive); |
2704 BeginTransactionL(); |
2700 BeginTransactionL(); |
2705 TRAPD(err, iDbAuxiliary->SetDBCorruptedL( ETrue ) ); |
2701 TRAPD(err, iDbAuxiliary->SetDBCorruptedL( ETrue ) ); |
2706 EndTransactionL( err ); |
2702 EndTransactionL( err ); |
2707 } |
2703 } |
2708 } |
2704 } |
2709 // Unmatched volume id, mark db as corrupt and break |
2705 // Unmatched volume id, mark db as corrupt and break |
2710 // |
2706 // |
2711 else if ( (curId&0x7FFFFFFF) != (volId&0x7FFFFFFFF) ) |
2707 else if ( (curId&0x7FFFFFFF) != (volId&0x7FFFFFFFF) ) |
2712 { |
2708 { |
2713 MPX_DEBUG1("CMPXDbHandler::VerifyVolumeIdL -- ID match FAILED"); |
2709 MPX_DEBUG1("CMPXDbHandler::VerifyVolumeIdL -- ID match FAILED"); |
2714 iDbManager->RecreateDatabaseL(iDbDrives[i]); |
2710 iDbManager->RecreateDatabaseL(aDrive); |
2715 BeginTransactionL(); |
2711 BeginTransactionL(); |
2716 TRAPD(err, iDbAuxiliary->SetDBCorruptedL( ETrue ) ); |
2712 TRAPD(err, iDbAuxiliary->SetDBCorruptedL( ETrue ) ); |
2717 EndTransactionL( err ); |
2713 EndTransactionL( err ); |
2718 } |
2714 } |
2719 } |
2715 } |
|
2716 |
|
2717 MPX_DEBUG1("CMPXDbHandler::VerifyVolumeIdL -->"); |
|
2718 } |
|
2719 |
|
2720 // ---------------------------------------------------------------------------- |
|
2721 // Verifies that the volume ID of the database matches the drive |
|
2722 // ---------------------------------------------------------------------------- |
|
2723 // |
|
2724 void CMPXDbHandler::VerifyVolumeIdL() |
|
2725 { |
|
2726 MPX_DEBUG1("CMPXDbHandler::VerifyVolumeIdL <--"); |
|
2727 TInt count( iDbDrives.Count() ); |
|
2728 for( TInt i=0; i<count; ++i ) |
|
2729 { |
|
2730 VerifyVolumeIdL(iDbDrives[i]); |
2720 } |
2731 } |
2721 MPX_DEBUG1("CMPXDbHandler::VerifyVolumeIdL -->"); |
2732 MPX_DEBUG1("CMPXDbHandler::VerifyVolumeIdL -->"); |
2722 } |
2733 } |
2723 |
2734 |
2724 |
2735 |