ConfigFile: Create the directory when using --confdir and it does not exist
authorOlivier Goffart <ogoffart@woboq.com>
Wed, 13 Jan 2016 09:31:02 +0000 (10:31 +0100)
committerOlivier Goffart <ogoffart@woboq.com>
Wed, 13 Jan 2016 09:31:02 +0000 (10:31 +0100)
Previously we would fail to start if the directory was not existing.
This was working for relative directory, but it should also work for
absolute ones

https://github.com/owncloud/enterprise/issues/970

src/libsync/configfile.cpp

index 2917be13f4012f9c08b1f8fe2717cfada89268eb..af54772b6731b6ce9364b809918b4648bb95bcaf 100644 (file)
@@ -95,11 +95,9 @@ bool ConfigFile::setConfDir(const QString &value)
     if( dirPath.isEmpty() ) return false;
 
     QFileInfo fi(dirPath);
-    if ( !fi.exists() && !fi.isAbsolute() ) {
-        QDir::current().mkdir(dirPath);
-        QDir dir = QDir::current();
-        dir.cd(dirPath);
-        fi.setFile(dir.path());
+    if ( !fi.exists()  ) {
+        QDir().mkpath(dirPath);
+        fi.setFile(dirPath);
     }
     if( fi.exists() && fi.isDir() ) {
         dirPath = fi.absoluteFilePath();