diff -r 1cae65a87b5e -r 9c56bf585696 engine/src/ShowEngine.cpp --- a/engine/src/ShowEngine.cpp Sat Oct 23 17:30:22 2010 +0100 +++ b/engine/src/ShowEngine.cpp Sat Nov 13 13:54:36 2010 +0000 @@ -162,7 +162,7 @@ void CShowEngine::Progress(CHttpClient* /*aHttpClient */, TInt aBytes, TInt aTotalBytes) { - iShowDownloading->SetShowSize(aTotalBytes); + //iShowDownloading->SetShowSize(aTotalBytes); TRAP_IGNORE(NotifyShowDownloadUpdatedL(aBytes, aTotalBytes)); } @@ -190,13 +190,25 @@ TFileName fileName; PodcastUtils::FileNameFromUrl(info->Url(), fileName); - TFileName extension; - extension.Copy(fileName.Mid(fileName.LocateReverse('.'))); - DP1("extension=%S", &extension); - TFileName newFilename; - newFilename.Format(_L("%u%S"), info->Uid(), &extension); - DP1("newFilename=%S", &newFilename); + + TInt periodPos = fileName.LocateReverse('.'); + + if (periodPos != -1) + { + // file extension (most likely) found + TFileName extension; + extension.Copy(fileName.Mid(periodPos)); + DP1("extension=%S", &extension); + + newFilename.Format(_L("%u%S"), info->Uid(), &extension); + DP1("newFilename=%S", &newFilename); + } + else + { + // no extension found, we'll have to rely on magic numbers + newFilename.Format(_L("%u"), info->Uid()); + } relPath.Append(newFilename); PodcastUtils::EnsureProperPathName(relPath); @@ -248,7 +260,8 @@ { if (iShowDownloading != NULL) { - DP2("CShowEngine::CompleteL file=%S, aError=%d", &iShowDownloading->FileName(), aError); + DP2("CShowEngine::CompleteL file=%S, aError=%d", &iShowDownloading->FileName(), aError); + if(aError != KErrCouldNotConnect) { if(aError == KErrDisconnected && iPodcastModel.SettingsEngine().DownloadSuspended()) @@ -274,6 +287,14 @@ { iShowDownloading->SetShowType(EVideoPodcast); } + + // setting file size + TEntry entry; + TInt err = iPodcastModel.FsSession().Entry(iShowDownloading->FileName(), entry); + if (err == KErrNone) + { + iShowDownloading->SetShowSize(entry.iSize); + } iShowDownloading->SetDownloadState(EDownloaded); DBUpdateShowL(*iShowDownloading); @@ -286,8 +307,16 @@ } else { + if (aError == HTTPStatus::ERequestedRangeNotSatisfiable) + { + DP("ERequestedRangeNotSatisfiable, resetting download"); + // file size got messed up, so delete downloaded file an re-queue + BaflUtils::DeleteFile(iPodcastModel.FsSession(),iShowDownloading->FileName()); + iShowDownloading->SetDownloadState(EQueued); + DBUpdateShowL(*iShowDownloading); + } // 400 and 500 series errors are serious errors on which probably another download will fail - if(aError >= HTTPStatus::EBadRequest && aError <= HTTPStatus::EBadRequest+200) + else if (aError>= HTTPStatus::EBadRequest && aError <= HTTPStatus::EBadRequest+200) { iShowDownloading->SetDownloadState(EFailedDownload); DBUpdateShowL(*iShowDownloading);