diff --git a/services/fileservice.cpp b/services/fileservice.cpp index d786884c157a57edae4e4166ecb7acae0c84aef4..6d7a7a69d29ee7856fb7a53147e30e197bfda268 100755 --- a/services/fileservice.cpp +++ b/services/fileservice.cpp @@ -79,6 +79,7 @@ bool FileService::getFileRessource( const QSharedPointer< FileRequest > &pReques auto tempFile = getFileFromCache( pRequest ); if ( !tempFile.isNull() ) { + if ( !pRequest->showInline ) { auto location = determineLocation( pRequest->url, pRequest->type, false ); QFile targetFile( location ); @@ -107,29 +108,28 @@ bool FileService::getFileRessource( const QSharedPointer< FileRequest > &pReques } } else { - if ( !tempFile->getFileChecked() ) { - QFile oldFile( tempFile->getFilePath() ); - - if ( oldFile.exists() ) { - tempFile->setFileChecked( true ); - } else { - mStorage->removeFileCacheEntry( pRequest->url, tempFile->getFilePath() ); - repo->remove( pRequest->url ); - getFileFromServer( pRequest ); - return false; - } - - /*if ( oldFile.copy( location ) ) { + QFile oldFile( tempFile->getFilePath() ); + QString path = location; + QStringList pathParts = location.split( "/" ); + pathParts.removeLast(); + QString dirStr = pathParts.join( "/" ); + QDir dir; + + if ( dir.mkpath( dirStr ) ) { + if ( oldFile.copy( location ) ) { tempFile = QSharedPointer<TempFile>::create( location, pRequest->url ); } else { qWarning() << oldFile.errorString(); - }*/ + } + } else { + qWarning() << "could not create: " << dirStr; } - } } + + pRequest->then( tempFile, pRequest->showInline ); } else { getFileFromServer( pRequest );