[Pkg-owncloud-commits] [owncloud-client] 41/333: Make owncloudcmd work with the parallel upload/download

Sandro Knauß hefee-guest at moszumanska.debian.org
Thu Apr 17 23:16:31 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 a39caa1cda3f4cde4294dcd13fb4c1d8eb621c8a
Author: Olivier Goffart <ogoffart at woboq.com>
Date:   Mon Feb 17 17:31:03 2014 +0100

    Make owncloudcmd work with the parallel upload/download
    
    Also make it work when there syncing a remote subfolder
---
 src/mirall/csyncthread.cpp             |  7 ++++---
 src/mirall/csyncthread.h               |  3 ++-
 src/mirall/folder.cpp                  |  2 +-
 src/mirall/owncloudpropagator.h        | 20 ++++++++++++++------
 src/mirall/owncloudpropagator_qnam.cpp |  4 ++--
 src/owncloudcmd/owncloudcmd.cpp        | 22 ++++++++++++++++++++--
 6 files changed, 43 insertions(+), 15 deletions(-)

diff --git a/src/mirall/csyncthread.cpp b/src/mirall/csyncthread.cpp
index ffd4fdd..31d1bb3 100644
--- a/src/mirall/csyncthread.cpp
+++ b/src/mirall/csyncthread.cpp
@@ -56,12 +56,13 @@ void csyncLogCatcher(int /*verbosity*/,
 /* static variables to hold the credentials */
 QMutex CSyncThread::_syncMutex;
 
-CSyncThread::CSyncThread(CSYNC *csync, const QString &localPath, const QString &remotePath, SyncJournalDb *journal)
+CSyncThread::CSyncThread(CSYNC *ctx, const QString& localPath, const QString& remoteURL, const QString& remotePath, Mirall::SyncJournalDb* journal)
     :_previousIndex(-1)
 {
     _localPath = localPath;
     _remotePath = remotePath;
-    _csync_ctx = csync;
+    _remoteUrl = remoteURL;
+    _csync_ctx = ctx;
     _journal = journal;
     qRegisterMetaType<SyncFileItem>("SyncFileItem");
     qRegisterMetaType<SyncFileItem::Status>("SyncFileItem::Status");
@@ -556,7 +557,7 @@ void CSyncThread::slotUpdateFinished(int updateResult)
     csync_set_module_property(_csync_ctx, "get_dav_session", &session);
     Q_ASSERT(session);
 
-    _propagator.reset(new OwncloudPropagator (session, _localPath, _remotePath,
+    _propagator.reset(new OwncloudPropagator (session, _localPath, _remoteUrl, _remotePath,
                                               _journal, &_thread));
     connect(_propagator.data(), SIGNAL(completed(SyncFileItem)),
             this, SLOT(transferCompleted(SyncFileItem)), Qt::QueuedConnection);
diff --git a/src/mirall/csyncthread.h b/src/mirall/csyncthread.h
index 5384dd5..d559169 100644
--- a/src/mirall/csyncthread.h
+++ b/src/mirall/csyncthread.h
@@ -48,7 +48,7 @@ class CSyncThread : public QObject
     Q_OBJECT
 
 public:
-    CSyncThread(CSYNC *, const QString &localPath, const QString &remotePath, SyncJournalDb *journal);
+    CSyncThread(CSYNC *, const QString &localPath, const QString &remoteURL, const QString &remotePath, SyncJournalDb *journal);
     ~CSyncThread();
 
     static QString csyncErrorToString( CSYNC_STATUS);
@@ -100,6 +100,7 @@ private:
     CSYNC *_csync_ctx;
     bool _needsUpdate;
     QString _localPath;
+    QString _remoteUrl;
     QString _remotePath;
     SyncJournalDb *_journal;
     QScopedPointer <OwncloudPropagator> _propagator;
diff --git a/src/mirall/folder.cpp b/src/mirall/folder.cpp
index cafcb11..22d7c69 100644
--- a/src/mirall/folder.cpp
+++ b/src/mirall/folder.cpp
@@ -552,7 +552,7 @@ void Folder::startSync(const QStringList &pathList)
 
     qDebug() << "*** Start syncing";
     setIgnoredFiles();
-    _csync = new CSyncThread( _csync_ctx, path(), remoteUrl().path(), &_journal);
+    _csync = new CSyncThread( _csync_ctx, path(), remoteUrl().path(), _remotePath, &_journal);
 
     qRegisterMetaType<SyncFileItemVector>("SyncFileItemVector");
     qRegisterMetaType<SyncFileItem::Direction>("SyncFileItem::Direction");
diff --git a/src/mirall/owncloudpropagator.h b/src/mirall/owncloudpropagator.h
index 5ae00af..a66a0a1 100644
--- a/src/mirall/owncloudpropagator.h
+++ b/src/mirall/owncloudpropagator.h
@@ -165,19 +165,25 @@ class OwncloudPropagator : public QObject {
     QScopedPointer<PropagateDirectory> _rootJob;
 
 public:
+    /* 'const' because they are accessed by the thread */
+
     QThread* _neonThread;
-    ne_session_s *_session;
+    ne_session_s * const _session;
+
     const QString _localDir; // absolute path to the local directory. ends with '/'
-    const QString _remoteDir; // path to the root of the remote. ends with '/'
-    SyncJournalDb *_journal;
+    const QString _remoteDir; // path to the root of the remote. ends with '/'  (include remote.php/webdav)
+    const QString _remoteFolder; // folder. (same as remoteDir but without remote.php/webdav)
+
+    SyncJournalDb * const _journal;
 
 public:
-    OwncloudPropagator(ne_session_s *session, const QString &localDir, const QString &remoteDir,
+    OwncloudPropagator(ne_session_s *session, const QString &localDir, const QString &remoteDir, const QString &remoteFolder,
                        SyncJournalDb *progressDb, QThread *neonThread)
             : _neonThread(neonThread)
             , _session(session)
-            , _localDir((localDir.endsWith(QChar('/'))) ? localDir : localDir+'/'  )
-            , _remoteDir((remoteDir.endsWith(QChar('/'))) ? remoteDir : remoteDir+'/'  )
+            , _localDir((localDir.endsWith(QChar('/'))) ? localDir : localDir+'/' )
+            , _remoteDir((remoteDir.endsWith(QChar('/'))) ? remoteDir : remoteDir+'/' )
+            , _remoteFolder((remoteFolder.endsWith(QChar('/'))) ? remoteFolder : remoteFolder+'/' )
             , _journal(progressDb)
             , _activeJobs(0)
     { }
@@ -203,6 +209,8 @@ public:
             _rootJob->abort();
         emit finished();
     }
+
+
 signals:
     void completed(const SyncFileItem &);
     void progress(Progress::Kind kind, const SyncFileItem&, quint64 bytes, quint64 total);
diff --git a/src/mirall/owncloudpropagator_qnam.cpp b/src/mirall/owncloudpropagator_qnam.cpp
index a8db43d..08d35b0 100644
--- a/src/mirall/owncloudpropagator_qnam.cpp
+++ b/src/mirall/owncloudpropagator_qnam.cpp
@@ -145,7 +145,7 @@ void PropagateUploadFileQNAM::startNextChunk()
         device = _file;
     }
 
-    _job = new PUTFileJob(AccountManager::instance()->account(), path, device, headers);
+    _job = new PUTFileJob(AccountManager::instance()->account(), _propagator->_remoteFolder + path, device, headers);
     connect(_job, SIGNAL(finishedSignal()), this, SLOT(slotPutFinished()));
     _job->start();
 }
@@ -382,7 +382,7 @@ void PropagateDownloadFileQNAM::start()
         qDebug() << "Retry with range " << headers["Range"];
     }
 
-    _job = new GETFileJob(AccountManager::instance()->account(), _item._file, &_tmpFile, headers);
+    _job = new GETFileJob(AccountManager::instance()->account(), _propagator->_remoteFolder + _item._file, &_tmpFile, headers);
     connect(_job, SIGNAL(finishedSignal()), this, SLOT(slotGetFinished()));
     _propagator->_activeJobs ++;
     _job->start();
diff --git a/src/owncloudcmd/owncloudcmd.cpp b/src/owncloudcmd/owncloudcmd.cpp
index d8e53a6..6bf02a8 100644
--- a/src/owncloudcmd/owncloudcmd.cpp
+++ b/src/owncloudcmd/owncloudcmd.cpp
@@ -27,10 +27,13 @@
 #include "logger.h"
 #include "csync.h"
 #include "mirall/clientproxy.h"
+#include "account.h"
+#include <creds/httpcredentials.h>
 
 using namespace Mirall;
 
-int getauth(const char* prompt, char* buf, size_t len, int echo, int verify, void*)
+
+int getauth(const char* prompt, char* buf, size_t len, int, int, void*)
 {
     std::cout << "** Authentication required: \n" << prompt << std::endl;
     std::string s;
@@ -115,6 +118,21 @@ int main(int argc, char **argv) {
 
     parseOptions( app.arguments(), &options );
 
+
+    QUrl url(options.target_url.toUtf8());
+    Account account;
+
+    // Find the folder and the original owncloud url
+    QStringList splitted = url.path().split(Account::davPath());
+    url.setPath(splitted.value(0));
+    url.setScheme(url.scheme().replace("owncloud", "http"));
+    QString folder = splitted.value(1);
+
+    account.setUrl(url);
+    account.setCredentials(new HttpCredentials(url.userName(), url.password()));
+    AccountManager::instance()->setAccount(&account);
+
+
     CSYNC *_csync_ctx;
     if( csync_create( &_csync_ctx, options.source_dir.toUtf8(),
                       options.target_url.toUtf8()) < 0 ) {
@@ -175,7 +193,7 @@ int main(int argc, char **argv) {
     }
 
     SyncJournalDb db(options.source_dir);
-    CSyncThread csyncthread(_csync_ctx, options.source_dir, QUrl(options.target_url).path(), &db);
+    CSyncThread csyncthread(_csync_ctx, options.source_dir, QUrl(options.target_url).path(), folder, &db);
     QObject::connect(&csyncthread, SIGNAL(finished()), &app, SLOT(quit()));
     csyncthread.startSync();
 

-- 
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