From 63bc58b736c5a4cb5db331b5363866a7b9096320 Mon Sep 17 00:00:00 2001
From: Armin Felder <armin.felder@osalliance.com>
Date: Wed, 26 Dec 2018 12:11:30 +0100
Subject: [PATCH] fix dir creation

---
 services/fileservice.cpp | 30 +++++++++++++++---------------
 1 file changed, 15 insertions(+), 15 deletions(-)

diff --git a/services/fileservice.cpp b/services/fileservice.cpp
index d786884..6d7a7a6 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 );
-- 
GitLab