647 // ok if not found - might have been deleted. |
647 // ok if not found - might have been deleted. |
648 //the ".bak" file, if exists, will be deleted first. |
648 //the ".bak" file, if exists, will be deleted first. |
649 (void)iInterface->Fs().Delete(bak); |
649 (void)iInterface->Fs().Delete(bak); |
650 TInt err=iInterface->Fs().Rename(db,bak); |
650 TInt err=iInterface->Fs().Rename(db,bak); |
651 SQL_TRACE_BUR(OstTraceExt4(TRACE_INTERNALS, CSQLBACKUPCLIENT_RESTOREBASEDATASECTONL5, "0x%X;CSqlBackupClient::RestoreBaseDataSectionL;END;bak=%S;db=%S;err=%d", (TUint)this, __SQLPRNSTR(bak), __SQLPRNSTR(db), err)); |
651 SQL_TRACE_BUR(OstTraceExt4(TRACE_INTERNALS, CSQLBACKUPCLIENT_RESTOREBASEDATASECTONL5, "0x%X;CSqlBackupClient::RestoreBaseDataSectionL;END;bak=%S;db=%S;err=%d", (TUint)this, __SQLPRNSTR(bak), __SQLPRNSTR(db), err)); |
652 if(err!=KErrNone && err!=KErrNotFound) |
652 if(err == KErrNone || err == KErrNotFound) |
653 { |
653 { |
654 __SQLLEAVE(err); |
654 // now, rename the .rst as .db |
|
655 err = iInterface->Fs().Rename(rst,db); |
655 } |
656 } |
656 |
|
657 // now, rename the .rst as .db |
|
658 err = iInterface->Fs().Rename(rst,db); |
|
659 if(err != KErrNone && err2 == KErrNone) |
657 if(err != KErrNone && err2 == KErrNone) |
660 { |
658 { |
661 //The idea here is to not report the error immediatelly by calling LeaveIfError(). |
659 //The idea here is to not report the error immediatelly by calling LeaveIfError(). |
662 //If we leave here, the next database restore may also fail, for example, if the current database is still open by |
660 //If we leave here, the next database restore may also fail, for example, if the current database is still open by |
663 //its owner. Then "TInt err=iInterface->Fs().Rename(db,bak);" will fail again. |
661 //its owner. Then "TInt err=iInterface->Fs().Rename(db,bak);" will fail again. |
664 err2 = err; |
662 err2 = err; |
665 } |
663 } |
666 // if we got here, we have a backup of the original database in .db.bak |
664 // if we got here, we have a backup of the original database in .db.bak |
667 // and the new database in .db |
665 // and the new database in .db |
668 } |
666 }//end of for(...) |
669 __SQLLEAVE_IF_ERROR(err2); |
667 __SQLLEAVE_IF_ERROR(err2); |
670 |
668 |
671 // clean up dir |
669 // clean up dir |
672 //delete dir; |
670 //delete dir; |
673 CleanupStack::PopAndDestroy(dir); |
671 CleanupStack::PopAndDestroy(dir); |