360 version = aReadStream.ReadInt32L(); |
360 version = aReadStream.ReadInt32L(); |
361 if ( version == KCacheVersionNumber ) |
361 if ( version == KCacheVersionNumber ) |
362 { |
362 { |
363 // read directory stub and validate it |
363 // read directory stub and validate it |
364 TInt len = aReadStream.ReadInt32L(); |
364 TInt len = aReadStream.ReadInt32L(); |
|
365 if(!len) |
|
366 return; |
|
367 |
365 HBufC* dirstub = HBufC::NewLC(len); |
368 HBufC* dirstub = HBufC::NewLC(len); |
366 TPtr dirstubptr = dirstub->Des(); |
369 TPtr dirstubptr = dirstub->Des(); |
367 aReadStream.ReadL( dirstubptr, len ); |
370 aReadStream.ReadL( dirstubptr, len ); |
368 ASSERT( aDirectory.CompareF( dirstubptr ) == 0 ); |
371 ASSERT( aDirectory.CompareF( dirstubptr ) == 0 ); |
369 CleanupStack::PopAndDestroy( dirstub ); |
372 CleanupStack::PopAndDestroy( dirstub ); |
794 // ----------------------------------------------------------------------------- |
797 // ----------------------------------------------------------------------------- |
795 // CHttpCacheLookupTable::MergeL |
798 // CHttpCacheLookupTable::MergeL |
796 // |
799 // |
797 // ----------------------------------------------------------------------------- |
800 // ----------------------------------------------------------------------------- |
798 // |
801 // |
799 void CHttpCacheLookupTable::MergeL( CHttpCacheLookupTable* aHttpCacheLookupTable, RFs aRfs ) |
802 void CHttpCacheLookupTable::MergeL( CHttpCacheLookupTable* aHttpCacheLookupTable, RFs aRfs, const TDesC& aDirectory ) |
800 { |
803 { |
|
804 CHttpCacheFileHash *onDiskFilesMap = NULL; |
|
805 |
|
806 // creating this object will use some memory, so this may fail. |
|
807 TRAPD(err, HttpCacheUtil::GenerateCacheContentHashMapL( onDiskFilesMap, aRfs, aDirectory , 0 )); |
|
808 // if it does fail, we fall back to examining the disk. |
|
809 if(err != KErrNone) |
|
810 { |
|
811 onDiskFilesMap = NULL; |
|
812 } |
|
813 else |
|
814 { |
|
815 CleanupStack::PushL( onDiskFilesMap ); |
|
816 } |
|
817 |
801 TInt myCount = iEntries->Count(); |
818 TInt myCount = iEntries->Count(); |
802 TInt i = 0; |
819 TInt i = 0; |
803 for (i = myCount - 1; i >= 0; i--) |
820 for (i = myCount - 1; i >= 0; i--) |
804 { |
821 { |
805 if ( Valid( i ) ) |
822 if ( Valid( i ) ) |
822 } |
839 } |
823 } |
840 } |
824 else // (newEntry) |
841 else // (newEntry) |
825 { |
842 { |
826 // Entry is not in the new index file |
843 // Entry is not in the new index file |
|
844 // Entry is in RAM index, may not be on disk yet due to postpone operation. |
827 TUint att; |
845 TUint att; |
828 if (aRfs.Att(entry->Filename(), att) != KErrNone) |
846 if ( !entry->BodyDataCached() && (onDiskFilesMap ? onDiskFilesMap->HashMap().Find( entry->Filename() ) == NULL : (aRfs.Att(entry->Filename(), att) != KErrNone)) ) |
829 { |
847 { |
830 TInt thePos = Probe(entry->Url(), EFalse); |
848 TInt thePos = Probe(entry->Url(), EFalse); |
831 if (Valid(thePos)) |
849 if (Valid(thePos)) |
832 { |
850 { |
833 Erase(thePos); |
851 Erase(thePos); |
843 if ( aHttpCacheLookupTable->Valid( i ) ) |
861 if ( aHttpCacheLookupTable->Valid( i ) ) |
844 { |
862 { |
845 CHttpCacheEntry* newEntry = aHttpCacheLookupTable->iEntries->At(i); |
863 CHttpCacheEntry* newEntry = aHttpCacheLookupTable->iEntries->At(i); |
846 TInt pos = aHttpCacheLookupTable->Probe(newEntry->Url(), EFalse); |
864 TInt pos = aHttpCacheLookupTable->Probe(newEntry->Url(), EFalse); |
847 TUint att; |
865 TUint att; |
848 if (aRfs.Att(newEntry->Filename(), att) == KErrNone) |
866 if ( onDiskFilesMap ? (onDiskFilesMap->HashMap().Find(newEntry->Filename()) != NULL ) : (aRfs.Att(newEntry->Filename(), att) == KErrNone) ) |
849 { |
867 { |
850 CHttpCacheEntry* myEntry = InsertL(newEntry->Url()); |
868 CHttpCacheEntry* myEntry = InsertL(newEntry->Url()); |
851 myEntry->SetState( CHttpCacheEntry::ECacheComplete ); |
869 myEntry->SetState( CHttpCacheEntry::ECacheComplete ); |
852 myEntry->Accessed(newEntry->LastAccessed(), newEntry->Ref()); |
870 myEntry->Accessed(newEntry->LastAccessed(), newEntry->Ref()); |
853 } |
871 } |
854 aHttpCacheLookupTable->SetDeleted(pos); |
872 aHttpCacheLookupTable->SetDeleted(pos); |
855 delete newEntry; |
873 delete newEntry; |
856 aHttpCacheLookupTable->iCount--; |
874 aHttpCacheLookupTable->iCount--; |
857 } |
875 } |
858 } |
876 } |
|
877 |
|
878 if( onDiskFilesMap ) |
|
879 CleanupStack::PopAndDestroy( onDiskFilesMap ); |
859 } |
880 } |
860 |
881 |
861 // ----------------------------------------------------------------------------- |
882 // ----------------------------------------------------------------------------- |
862 // CHttpCacheLookupTable::BeginEntryIteration |
883 // CHttpCacheLookupTable::BeginEntryIteration |
863 // |
884 // |