[Pkg-owncloud-commits] [owncloud-client] 112/211: owncloudcmd: Always need exclude list

Sandro Knauß hefee-guest at moszumanska.debian.org
Sat Oct 25 09:10:34 UTC 2014


This is an automated email from the git hooks/post-receive script.

hefee-guest pushed a commit to branch master
in repository owncloud-client.

commit f1006ca8b092dde63d7c870b2dd18ce34283288e
Author: Markus Goetz <markus at woboq.com>
Date:   Fri Oct 17 15:58:01 2014 +0200

    owncloudcmd: Always need exclude list
    
    Try to load the system list or the user supplied list.
    
    For #2322
---
 src/mirall/mirallconfigfile.cpp | 46 +++++++++++++++++++++++------------------
 src/mirall/mirallconfigfile.h   |  1 +
 src/owncloudcmd/owncloudcmd.cpp | 17 ++++++++++++++-
 3 files changed, 43 insertions(+), 21 deletions(-)

diff --git a/src/mirall/mirallconfigfile.cpp b/src/mirall/mirallconfigfile.cpp
index d5089cd..84af425 100644
--- a/src/mirall/mirallconfigfile.cpp
+++ b/src/mirall/mirallconfigfile.cpp
@@ -206,15 +206,16 @@ QString MirallConfigFile::configPathWithAppName() const
     return QFileInfo( configFile() ).dir().absolutePath().append("/");
 }
 
+static const QLatin1String exclFile("sync-exclude.lst");
+
 QString MirallConfigFile::excludeFile(Scope scope) const
 {
     // prefer sync-exclude.lst, but if it does not exist, check for
     // exclude.lst for compatibility reasons in the user writeable
     // directories.
-    const QString exclFile("sync-exclude.lst");
-    QFileInfo fi;
 
     if (scope != SystemScope) {
+        QFileInfo fi;
         fi.setFile( configPath(), exclFile );
 
         if( ! fi.isReadable() ) {
@@ -223,32 +224,37 @@ QString MirallConfigFile::excludeFile(Scope scope) const
         if( ! fi.isReadable() ) {
             fi.setFile( configPath(), exclFile );
         }
+        return fi.absoluteFilePath();
+    } else if (scope != UserScope) {
+        return MirallConfigFile::excludeFileFromSystem();
+    } else {
+        Q_ASSERT(false);
+        return QString(); // unreachable
     }
+}
 
-    if (scope != UserScope) {
-        // Check alternative places...
-        if( ! fi.isReadable() ) {
+QString MirallConfigFile::excludeFileFromSystem()
+{
+    QFileInfo fi;
 #ifdef Q_OS_WIN
-            fi.setFile( QCoreApplication::applicationDirPath(), exclFile );
+    fi.setFile( QCoreApplication::applicationDirPath(), exclFile );
 #endif
 #ifdef Q_OS_UNIX
-            fi.setFile( QString( SYSCONFDIR "/%1").arg(Theme::instance()->appName()), exclFile );
-            if ( ! fi.exists() ) {
-                // Prefer to return the preferred path! Only use the fallback location
-                // if the other path does not exist and the fallback is valid.
-                QFileInfo nextToBinary( QCoreApplication::applicationDirPath(), exclFile );
-                if (nextToBinary.exists()) {
-                    fi = nextToBinary;
-                }
-            }
+    fi.setFile( QString( SYSCONFDIR "/%1").arg(Theme::instance()->appName()), exclFile );
+    if ( ! fi.exists() ) {
+        // Prefer to return the preferred path! Only use the fallback location
+        // if the other path does not exist and the fallback is valid.
+        QFileInfo nextToBinary( QCoreApplication::applicationDirPath(), exclFile );
+        if (nextToBinary.exists()) {
+            fi = nextToBinary;
+        }
+    }
 #endif
 #ifdef Q_OS_MAC
-            // exec path is inside the bundle
-            fi.setFile( QCoreApplication::applicationDirPath(),
-                        QLatin1String("../Resources/") + exclFile );
+    // exec path is inside the bundle
+    fi.setFile( QCoreApplication::applicationDirPath(),
+                QLatin1String("../Resources/") + exclFile );
 #endif
-        }
-    }
     return fi.absoluteFilePath();
 }
 
diff --git a/src/mirall/mirallconfigfile.h b/src/mirall/mirallconfigfile.h
index 8b7423f..6c5645c 100644
--- a/src/mirall/mirallconfigfile.h
+++ b/src/mirall/mirallconfigfile.h
@@ -38,6 +38,7 @@ public:
     QString configPathWithAppName() const;
     QString configFile() const;
     QString excludeFile(Scope scope) const;
+    static QString excludeFileFromSystem(); // doesn't access config dir
 
     bool exists();
 
diff --git a/src/owncloudcmd/owncloudcmd.cpp b/src/owncloudcmd/owncloudcmd.cpp
index f6bfbb2..9ac7e3a 100644
--- a/src/owncloudcmd/owncloudcmd.cpp
+++ b/src/owncloudcmd/owncloudcmd.cpp
@@ -27,6 +27,7 @@
 #include "csync.h"
 #include "mirall/clientproxy.h"
 #include "mirall/account.h"
+#include "mirall/mirallconfigfile.h" // ONLY ACCESS THE STATIC FUNCTIONS!
 #include "creds/httpcredentials.h"
 #include "owncloudcmd.h"
 #include "simplesslerrorhandler.h"
@@ -374,8 +375,22 @@ restart_sync:
         clientProxy.setCSyncProxy(QUrl(url), _csync_ctx);
     }
 
+    // Exclude lists
+    QString systemExcludeListFn = MirallConfigFile::excludeFileFromSystem();
+    int loadedSystemExcludeList = false;
+    if (!systemExcludeListFn.isEmpty()) {
+        loadedSystemExcludeList = csync_add_exclude_list(_csync_ctx, systemExcludeListFn.toLocal8Bit());
+    }
+
+    int loadedUserExcludeList = false;
     if (!options.exclude.isEmpty()) {
-        csync_add_exclude_list(_csync_ctx, options.exclude.toLocal8Bit());
+        loadedUserExcludeList = csync_add_exclude_list(_csync_ctx, options.exclude.toLocal8Bit());
+    }
+
+    if (loadedSystemExcludeList != 0 && loadedUserExcludeList != 0) {
+        // Always make sure at least one list had been loaded
+        qFatal("Cannot load system exclude list or list supplied via --exclude");
+        return EXIT_FAILURE;
     }
 
     cred->syncContextPreStart(_csync_ctx);

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud-client.git



More information about the Pkg-owncloud-commits mailing list