libsync: Don't store the remote URI in the csync or in the SyncEngine
authorOlivier Goffart <ogoffart@woboq.com>
Tue, 15 Nov 2016 17:47:04 +0000 (18:47 +0100)
committerOlivier Goffart <olivier@woboq.com>
Mon, 21 Nov 2016 07:09:11 +0000 (08:09 +0100)
We are going to change the webdav path depending on the capabilities.
But the SyncEngine and csync might have been created before the capabilities
are retrieved.

The main raison why we gave the path to the sync engine was to pass it to csync.
But the thing is that csync don't need anymore this url as everything is done by the
discovery classes in libsync that use the network jobs that use the account for the urls.
So csync do not need the remote URI.

shortenFilename in folderstatusmodel.cpp was useless because the string is the
_file of a SyncFileItem which is the relative file name, that name never
starts with owncloud://.

All the csync test creates the folder because csync use to check if the folder
exists. But we don't need to do that anymore

27 files changed:
csync/src/csync.c
csync/src/csync.h
csync/src/csync_private.h
csync/src/csync_update.c
csync/tests/csync_tests/check_csync_commit.c
csync/tests/csync_tests/check_csync_create.c
csync/tests/csync_tests/check_csync_exclude.c
csync/tests/csync_tests/check_csync_init.c
csync/tests/csync_tests/check_csync_log.c
csync/tests/csync_tests/check_csync_statedb_load.c
csync/tests/csync_tests/check_csync_statedb_query.c
csync/tests/csync_tests/check_csync_update.c
csync/tests/vio_tests/check_vio.c
csync/tests/vio_tests/check_vio_ext.c
src/cmd/cmd.cpp
src/gui/folder.cpp
src/gui/folderstatusmodel.cpp
src/libsync/owncloudpropagator.cpp
src/libsync/owncloudpropagator.h
src/libsync/propagateremotemove.cpp
src/libsync/propagateuploadng.cpp
src/libsync/syncengine.cpp
src/libsync/syncengine.h
src/libsync/utility.cpp
src/libsync/utility.h
test/syncenginetestutils.h
test/testutility.cpp

index 78660955ce9cbc3c74d55e9ce2074604dde91b81..9d850d4fb14b17b5040aa6c2b17c90834f7ff38b 100644 (file)
@@ -89,7 +89,7 @@ static int _data_cmp(const void *key, const void *data) {
   return 0;
 }
 
-void csync_create(CSYNC **csync, const char *local, const char *remote) {
+void csync_create(CSYNC **csync, const char *local) {
   CSYNC *ctx;
   size_t len = 0;
 
@@ -103,12 +103,6 @@ void csync_create(CSYNC **csync, const char *local, const char *remote) {
 
   ctx->local.uri = c_strndup(local, len);
 
-  /* remove trailing slashes */
-  len = strlen(remote);
-  while(len > 0 && remote[len - 1] == '/') --len;
-
-  ctx->remote.uri = c_strndup(remote, len);
-
   ctx->status_code = CSYNC_STATUS_OK;
 
   ctx->current_fs = NULL;
@@ -199,7 +193,7 @@ int csync_update(CSYNC *ctx) {
   ctx->current = REMOTE_REPLICA;
   ctx->replica = ctx->remote.type;
 
-  rc = csync_ftw(ctx, ctx->remote.uri, csync_walker, MAX_DEPTH);
+  rc = csync_ftw(ctx, "", csync_walker, MAX_DEPTH);
   if (rc < 0) {
       if(ctx->status_code == CSYNC_STATUS_OK) {
           ctx->status_code = csync_errno_to_status(errno, CSYNC_STATUS_UPDATE_ERROR);
@@ -579,7 +573,6 @@ int csync_destroy(CSYNC *ctx) {
   _csync_clean_ctx(ctx);
 
   SAFE_FREE(ctx->local.uri);
-  SAFE_FREE(ctx->remote.uri);
   SAFE_FREE(ctx->error_string);
 
 #ifdef WITH_ICONV
index d731bb5d703f7c6e1e0c67aafe7689f4919439d7..ea4f3d5647a94b95e0e147387c3ea6bb2c5fe945 100644 (file)
@@ -317,7 +317,7 @@ typedef const char* (*csync_checksum_hook) (
  *
  * @param csync  The context variable to allocate.
  */
-void OCSYNC_EXPORT csync_create(CSYNC **csync, const char *local, const char *remote);
+void OCSYNC_EXPORT csync_create(CSYNC **csync, const char *local);
 
 /**
  * @brief Initialize the file synchronizer.
index 0a507246608c560ab154cd18c587f98e29689867..a28eb82100c361055d6201ab920d28c937221362 100644 (file)
@@ -126,7 +126,6 @@ struct csync_s {
   } local;
 
   struct {
-    char *uri;
     c_rbtree_t *tree;
     enum csync_replica_e type;
     int  read_from_db;
index 2623b17c4578a93b957b3c93f17ea5901cc5b692..b5b34797195fbdeb05d3c29912e4fe2e5fcc90f2 100644 (file)
@@ -56,26 +56,13 @@ static uint64_t _hash_of_file(CSYNC *ctx, const char *file) {
 
   if( ctx && file ) {
     path = file;
-    switch (ctx->current) {
-    case LOCAL_REPLICA:
+    if (ctx->current == LOCAL_REPLICA) {
       if (strlen(path) <= strlen(ctx->local.uri)) {
         return 0;
       }
       path += strlen(ctx->local.uri) + 1;
-      break;
-    case REMOTE_REPLICA:
-      if (strlen(path) <= strlen(ctx->remote.uri)) {
-        return 0;
-      }
-      path += strlen(ctx->remote.uri) + 1;
-      break;
-    default:
-      path = NULL;
-      return 0;
-      break;
     }
     len = strlen(path);
-
     h = c_jhash64((uint8_t *) path, len, 0);
   }
   return h;
@@ -188,25 +175,12 @@ static int _csync_detect_update(CSYNC *ctx, const char *file,
   }
 
   path = file;
-  switch (ctx->current) {
-    case LOCAL_REPLICA:
+  if (ctx->current == LOCAL_REPLICA) {
       if (strlen(path) <= strlen(ctx->local.uri)) {
         ctx->status_code = CSYNC_STATUS_PARAM_ERROR;
         return -1;
       }
       path += strlen(ctx->local.uri) + 1;
-      break;
-    case REMOTE_REPLICA:
-      if (strlen(path) <= strlen(ctx->remote.uri)) {
-        ctx->status_code = CSYNC_STATUS_PARAM_ERROR;
-        return -1;
-      }
-      path += strlen(ctx->remote.uri) + 1;
-      break;
-    default:
-      path = NULL;
-      ctx->status_code = CSYNC_STATUS_PARAM_ERROR;
-      return -1;
   }
 
   len = strlen(path);
@@ -629,16 +603,7 @@ int csync_walker(CSYNC *ctx, const char *file, const csync_vio_file_stat_t *fs,
 
 static bool fill_tree_from_db(CSYNC *ctx, const char *uri)
 {
-    const char *path = NULL;
-
-    if( strlen(uri) < strlen(ctx->remote.uri)+1) {
-        CSYNC_LOG(CSYNC_LOG_PRIORITY_ERROR, "name does not contain remote uri!");
-        return false;
-    }
-
-    path = uri + strlen(ctx->remote.uri)+1;
-
-    if( csync_statedb_get_below_path(ctx, path) < 0 ) {
+    if( csync_statedb_get_below_path(ctx, uri) < 0 ) {
         CSYNC_LOG(CSYNC_LOG_PRIORITY_ERROR, "StateDB could not be read!");
         return false;
     }
@@ -680,12 +645,6 @@ int csync_ftw(CSYNC *ctx, const char *uri, csync_walker_fn fn,
 
   bool do_read_from_db = (ctx->current == REMOTE_REPLICA && ctx->remote.read_from_db);
 
-  if (uri[0] == '\0') {
-    errno = ENOENT;
-    ctx->status_code = CSYNC_STATUS_PARAM_ERROR;
-    goto error;
-  }
-
   read_from_db = ctx->remote.read_from_db;
 
   // if the etag of this dir is still the same, its content is restored from the
@@ -699,16 +658,7 @@ int csync_ftw(CSYNC *ctx, const char *uri, csync_walker_fn fn,
       goto done;
   }
 
-  const char *uri_for_vio = uri;
-  if (ctx->current == REMOTE_REPLICA) {
-      uri_for_vio += strlen(ctx->remote.uri);
-      if (strlen(uri_for_vio) > 0 && uri_for_vio[0] == '/') {
-          uri_for_vio++; // cut leading slash
-      }
-      CSYNC_LOG(CSYNC_LOG_PRIORITY_ERROR, "URI without fuzz for %s is \"%s\"", uri, uri_for_vio);
-  }
-
-  if ((dh = csync_vio_opendir(ctx, uri_for_vio)) == NULL) {
+  if ((dh = csync_vio_opendir(ctx, uri)) == NULL) {
       if (ctx->abort) {
           CSYNC_LOG(CSYNC_LOG_PRIORITY_TRACE, "Aborted!");
           ctx->status_code = CSYNC_STATUS_ABORTED;
@@ -781,34 +731,32 @@ int csync_ftw(CSYNC *ctx, const char *uri, csync_walker_fn fn,
       continue;
     }
 
-    flen = asprintf(&filename, "%s/%s", uri, d_name);
-    if (flen < 0) {
+    if (uri[0] == '\0') {
+      filename = c_strdup(d_name);
+      flen = strlen(d_name);
+    } else {
+      flen = asprintf(&filename, "%s/%s", uri, d_name);
+    }
+    if (flen < 0 || !filename) {
       csync_vio_file_stat_destroy(dirent);
       dirent = NULL;
       ctx->status_code = CSYNC_STATUS_MEMORY_ERROR;
       goto error;
     }
 
-    /* Create relative path */
-    switch (ctx->current) {
-      case LOCAL_REPLICA:
+    /* Create relative path: For local replica, we need to remove the base path.  */
+    path = filename;
+    if (ctx->current == LOCAL_REPLICA) {
         ulen = strlen(ctx->local.uri) + 1;
-        break;
-      case REMOTE_REPLICA:
-        ulen = strlen(ctx->remote.uri) + 1;
-        break;
-      default:
-        break;
-    }
-
-    if (((size_t)flen) < ulen) {
-      csync_vio_file_stat_destroy(dirent);
-      dirent = NULL;
-      ctx->status_code = CSYNC_STATUS_UNSUCCESSFUL;
-      goto error;
+        if (((size_t)flen) < ulen) {
+            csync_vio_file_stat_destroy(dirent);
+            dirent = NULL;
+            ctx->status_code = CSYNC_STATUS_UNSUCCESSFUL;
+            goto error;
+        }
+        path += ulen;
     }
 
-    path = filename + ulen;
 
     /* skip ".csync_journal.db" and ".csync_journal.db.ctmp" */
     /* Isn't this done via csync_exclude already? */
index 20d79fed9576a96cee875dd391c7f2a28bba7a48..679816af63935dd23dc6adb7dbf8f09d6f469360 100644 (file)
@@ -30,10 +30,7 @@ static void setup(void **state) {
     rc = system("mkdir -p /tmp/check_csync1");
     assert_int_equal(rc, 0);
 
-    rc = system("mkdir -p /tmp/check_csync2");
-    assert_int_equal(rc, 0);
-
-    csync_create(&csync, "/tmp/check_csync1", "/tmp/check_csync2");
+    csync_create(&csync, "/tmp/check_csync1");
 
     *state = csync;
 }
@@ -45,10 +42,7 @@ static void setup_module(void **state) {
     rc = system("mkdir -p /tmp/check_csync1");
     assert_int_equal(rc, 0);
 
-    rc = system("mkdir -p /tmp/check_csync2");
-    assert_int_equal(rc, 0);
-
-    csync_create(&csync, "/tmp/check_csync1", "dummy://foo/bar");
+    csync_create(&csync, "/tmp/check_csync1");
 
     csync_init(csync);
     *state = csync;
@@ -66,9 +60,6 @@ static void teardown(void **state) {
     rc = system("rm -rf /tmp/check_csync1");
     assert_int_equal(rc, 0);
 
-    rc = system("rm -rf /tmp/check_csync2");
-    assert_int_equal(rc, 0);
-
     *state = NULL;
 }
 
index 8f2f61fb3e2ad03e61c5b508cc1d9850dd57c4a2..3a905abf3fc10fd3cdb702fed1d39340345d5fb3 100644 (file)
@@ -42,7 +42,7 @@ static void check_csync_create(void **state)
 
     (void) state; /* unused */
 
-    csync_create(&csync, "/tmp/csync1", "/tmp/csync2");
+    csync_create(&csync, "/tmp/csync1");
 
     rc = csync_destroy(csync);
     assert_int_equal(rc, 0);
index b788c1c3ce0e24e7778421890ca163f625c073c4..b0f52a59f853fd8e7e7d5cadb98e9ab63417f47b 100644 (file)
@@ -32,7 +32,7 @@
 static void setup(void **state) {
     CSYNC *csync;
 
-    csync_create(&csync, "/tmp/check_csync1", "/tmp/check_csync2");
+    csync_create(&csync, "/tmp/check_csync1");
 
     *state = csync;
 }
@@ -41,7 +41,7 @@ static void setup_init(void **state) {
     CSYNC *csync;
     int rc;
 
-    csync_create(&csync, "/tmp/check_csync1", "/tmp/check_csync2");
+    csync_create(&csync, "/tmp/check_csync1");
 
     rc = csync_exclude_load(EXCLUDE_LIST_FILE, &(csync->excludes));
     assert_int_equal(rc, 0);
index eb8ec8da95fdc0e39716c2cbe4ea34a57d846ffd..44dedbefd58738251cdc6c09f28aa7a5bb17ef97 100644 (file)
@@ -30,10 +30,7 @@ static void setup(void **state) {
     rc = system("mkdir -p /tmp/check_csync1");
     assert_int_equal(rc, 0);
 
-    rc = system("mkdir -p /tmp/check_csync2");
-    assert_int_equal(rc, 0);
-
-    csync_create(&csync, "/tmp/check_csync1", "/tmp/check_csync2");
+    csync_create(&csync, "/tmp/check_csync1");
 
     *state = csync;
 }
@@ -45,10 +42,7 @@ static void setup_module(void **state) {
     rc = system("mkdir -p /tmp/check_csync1");
     assert_int_equal(rc, 0);
 
-    rc = system("mkdir -p /tmp/check_csync2");
-    assert_int_equal(rc, 0);
-
-    csync_create(&csync, "/tmp/check_csync1", "dummy://foo/bar");
+    csync_create(&csync, "/tmp/check_csync1");
 
     *state = csync;
 }
@@ -65,9 +59,6 @@ static void teardown(void **state) {
     rc = system("rm -rf /tmp/check_csync1");
     assert_int_equal(rc, 0);
 
-    rc = system("rm -rf /tmp/check_csync2");
-    assert_int_equal(rc, 0);
-
     *state = NULL;
 }
 
index a888447e316be76d428bb4923182fe87872522e5..7ad7e1bc881de6179d7833e55e40477019cd01c4 100644 (file)
@@ -33,10 +33,7 @@ static void setup(void **state) {
     rc = system("mkdir -p /tmp/check_csync1");
     assert_int_equal(rc, 0);
 
-    rc = system("mkdir -p /tmp/check_csync2");
-    assert_int_equal(rc, 0);
-
-    csync_create(&csync, "/tmp/check_csync1", "/tmp/check_csync2");
+    csync_create(&csync, "/tmp/check_csync1");
 
     *state = csync;
 }
@@ -53,9 +50,6 @@ static void teardown(void **state) {
     rc = system("rm -rf /tmp/check_csync1");
     assert_int_equal(rc, 0);
 
-    rc = system("rm -rf /tmp/check_csync2");
-    assert_int_equal(rc, 0);
-
     *state = NULL;
 }
 
index c18c5a47e3f03bec73e93ed9f01a4c3cdc9fe804..0fabc4e60ef7f1d091f96489f76ec6ca702ed4d8 100644 (file)
@@ -36,7 +36,7 @@ static void setup(void **state) {
     rc = system("mkdir -p /tmp/check_csync1");
     assert_int_equal(rc, 0);
 
-    csync_create(&csync, "/tmp/check_csync1", "/tmp/check_csync2");
+    csync_create(&csync, "/tmp/check_csync1");
 
     csync->statedb.file = c_strdup( TESTDB );
     *state = csync;
index 0ce8bde5f9ee92b03c11db7f3b6736ef32e3ac1b..63459e9e2e8f3bf9fec219577d555bcd1ae3d3b7 100644 (file)
@@ -34,15 +34,11 @@ static void setup(void **state)
 
     rc = system("rm -rf /tmp/check_csync1");
     assert_int_equal(rc, 0);
-    rc = system("rm -rf /tmp/check_csync2");
-    assert_int_equal(rc, 0);
     rc = system("mkdir -p /tmp/check_csync1");
     assert_int_equal(rc, 0);
-    rc = system("mkdir -p /tmp/check_csync2");
-    assert_int_equal(rc, 0);
     rc = system("mkdir -p /tmp/check_csync");
     assert_int_equal(rc, 0);
-    csync_create(&csync, "/tmp/check_csync1", "/tmp/check_csync2");
+    csync_create(&csync, "/tmp/check_csync1");
     csync_init(csync);
 
     sqlite3 *db = NULL;
@@ -106,8 +102,6 @@ static void teardown(void **state) {
     assert_int_equal(rc, 0);
     rc = system("rm -rf /tmp/check_csync1");
     assert_int_equal(rc, 0);
-    rc = system("rm -rf /tmp/check_csync2");
-    assert_int_equal(rc, 0);
 
     *state = NULL;
 }
index a95421747ac54ce8cbf62496345ac348e2db6844..9f8c8abe58260abce7dd3db5df8735cb41d9e578 100644 (file)
@@ -91,9 +91,7 @@ static void setup(void **state)
     assert_int_equal(rc, 0);
     rc = system("mkdir -p /tmp/check_csync1");
     assert_int_equal(rc, 0);
-    rc = system("mkdir -p /tmp/check_csync2");
-    assert_int_equal(rc, 0);
-    csync_create(&csync, "/tmp/check_csync1", "/tmp/check_csync2");
+    csync_create(&csync, "/tmp/check_csync1");
     csync_init(csync);
 
     /* Create a new db with metadata */
@@ -122,9 +120,7 @@ static void setup_ftw(void **state)
     assert_int_equal(rc, 0);
     rc = system("mkdir -p /tmp/check_csync1");
     assert_int_equal(rc, 0);
-    rc = system("mkdir -p /tmp/check_csync2");
-    assert_int_equal(rc, 0);
-    csync_create(&csync, "/tmp", "/tmp");
+    csync_create(&csync, "/tmp");
     csync_init(csync);
 
     sqlite3 *db = NULL;
@@ -162,8 +158,6 @@ static void teardown_rm(void **state) {
     assert_int_equal(rc, 0);
     rc = system("rm -rf /tmp/check_csync1");
     assert_int_equal(rc, 0);
-    rc = system("rm -rf /tmp/check_csync2");
-    assert_int_equal(rc, 0);
 }
 
 /* create a file stat, caller must free memory */
index e8d716f400421e6974d5b55e6036088045be89d6..6d4afd7efdf54a5b72ba2c2aa503973214775f52 100644 (file)
@@ -48,7 +48,7 @@ static void setup(void **state)
     rc = system("rm -rf /tmp/csync_test");
     assert_int_equal(rc, 0);
 
-    csync_create(&csync, "/tmp/csync1", "/tmp/csync2");
+    csync_create(&csync, "/tmp/csync1");
 
     csync->replica = LOCAL_REPLICA;
 
index 5642d76fcc64a113e0de3c51e844fae860fca838..f91328767e20c629f7104f89511f0847b059405e 100644 (file)
@@ -96,7 +96,7 @@ static void setup_testenv(void **state) {
     statevar *mystate = malloc( sizeof(statevar) );
     mystate->result = NULL;
 
-    csync_create(&(mystate->csync), "/tmp/csync1", "/tmp/csync2");
+    csync_create(&(mystate->csync), "/tmp/csync1");
 
     mystate->csync->replica = LOCAL_REPLICA;
 
index 17a713735b8bf835fcd6e5cc3d9b0c5e24b701f0..a37de2853a014d8dea97c6c2a0b43091e26c793d 100644 (file)
@@ -475,7 +475,7 @@ restart_sync:
         selectiveSyncFixup(&db, selectiveSyncList);
     }
 
-    SyncEngine engine(account, options.source_dir, QUrl(options.target_url), folder, &db);
+    SyncEngine engine(account, options.source_dir, folder, &db);
     engine.setIgnoreHiddenFiles(options.ignoreHiddenFiles);
     QObject::connect(&engine, SIGNAL(finished(bool)), &app, SLOT(quit()));
     QObject::connect(&engine, SIGNAL(transmissionProgress(ProgressInfo)), &cmd, SLOT(transmissionProgressSlot()));
index bc2dca76cffdcad132ca53d1484744f164e9dd36..8b44c1b32c9806bc21b54d6fbe400b68537b94a5 100644 (file)
@@ -81,7 +81,7 @@ Folder::Folder(const FolderDefinition& definition,
 
     _syncResult.setFolder(_definition.alias);
 
-    _engine.reset(new SyncEngine(_accountState->account(), path(), remoteUrl(), remotePath(), &_journal));
+    _engine.reset(new SyncEngine(_accountState->account(), path(), remotePath(), &_journal));
     // pass the setting if hidden files are to be ignored, will be read in csync_update
     _engine->setIgnoreHiddenFiles(_definition.ignoreHiddenFiles);
 
index 3bed5bcba9b22427405477518f0adadf887c2509..1bd5fcc257707c7c6b84c98b218bb905efa07f93 100644 (file)
@@ -806,25 +806,6 @@ void FolderStatusModel::slotApplySelectiveSync()
     resetFolders();
 }
 
-static QString shortenFilename( Folder *f, const QString& file )
-{
-    // strip off the server prefix from the file name
-    QString shortFile(file);
-    if( shortFile.isEmpty() ) {
-        return QString::null;
-    }
-
-    if(shortFile.startsWith(QLatin1String("ownclouds://")) ||
-            shortFile.startsWith(QLatin1String("owncloud://")) ) {
-        // rip off the whole ownCloud URL.
-        if( f ) {
-            QString remotePathUrl = f->remoteUrl().toString();
-            shortFile.remove(Utility::toCSyncScheme(remotePathUrl));
-        }
-    }
-    return shortFile;
-}
-
 void FolderStatusModel::slotSetProgress(const ProgressInfo &progress)
 {
     auto par = qobject_cast<QWidget*>(QObject::parent());
@@ -898,7 +879,7 @@ void FolderStatusModel::slotSetProgress(const ProgressInfo &progress)
         curItemProgress = curItem._size;
     }
 
-    QString itemFileName = shortenFilename(f, curItem._file);
+    QString itemFileName = curItem._file;
     QString kindString = Progress::asActionString(curItem);
 
     QString fileProgressString;
index d8ad23ea9dd48c1a47f12a55ea746f88eb8b0715..213896abe5fa4cbced6fc3e728f8229b20df84bc 100644 (file)
@@ -412,10 +412,12 @@ void OwncloudPropagator::start(const SyncFileItemVector& items)
     QTimer::singleShot(0, this, SLOT(scheduleNextJob()));
 }
 
+// ownCloud server  < 7.0 did not had permissions so we need some other euristics
+// to detect wrong doing in a Shared directory
 bool OwncloudPropagator::isInSharedDirectory(const QString& file)
 {
     bool re = false;
-    if( _remoteDir.contains( _account->davPath() + QLatin1String("Shared") ) ) {
+    if( _remoteFolder.startsWith( QLatin1String("Shared") ) ) {
         // The Shared directory is synced as its own sync connection
         re = true;
     } else {
index 3c69306629255cca68a48475257c61dbbb3e32bd..1097b7f8747be875b99c8583956c540b71a175b3 100644 (file)
@@ -267,8 +267,7 @@ class OwncloudPropagator : public QObject {
 
 public:
     const QString _localDir; // absolute path to the local directory. ends with '/'
-    const QString _remoteDir; // path to the root of the remote. ends with '/'  (include WebDAV path)
-    const QString _remoteFolder; // folder. (same as remoteDir but without the WebDAV path)
+    const QString _remoteFolder; // remote folder, ends with '/'
 
     SyncJournalDb * const _journal;
     bool _finishedEmited; // used to ensure that finished is only emitted once
@@ -276,10 +275,8 @@ public:
 
 public:
     OwncloudPropagator(AccountPtr account, const QString &localDir,
-                       const QString &remoteDir, const QString &remoteFolder,
-                       SyncJournalDb *progressDb)
+                       const QString &remoteFolder, SyncJournalDb *progressDb)
             : _localDir((localDir.endsWith(QChar('/'))) ? localDir : localDir+'/' )
-            , _remoteDir((remoteDir.endsWith(QChar('/'))) ? remoteDir : remoteDir+'/' )
             , _remoteFolder((remoteFolder.endsWith(QChar('/'))) ? remoteFolder : remoteFolder+'/' )
             , _journal(progressDb)
             , _finishedEmited(false)
index bcceec709f13f4f4c872335ea231df3fae7516d5..6b6c8b6dae42e2d4eb7bb9cbc6d53cf6bd315c50 100644 (file)
@@ -20,6 +20,7 @@
 #include "filesystem.h"
 #include <QFile>
 #include <QStringList>
+#include <QDir>
 
 namespace OCC {
 
@@ -101,10 +102,11 @@ void PropagateRemoteMove::start()
         }
     }
 
+    QString destination = QDir::cleanPath(_propagator->account()->url().path() + QLatin1Char('/')
+            + _propagator->account()->davPath() + _propagator->_remoteFolder + _item->_renameTarget);
     _job = new MoveJob(_propagator->account(),
                         _propagator->_remoteFolder + _item->_file,
-                        _propagator->_remoteDir + _item->_renameTarget,
-                        this);
+                        destination, this);
     connect(_job, SIGNAL(finishedSignal()), this, SLOT(slotMoveJobFinished()));
     _propagator->_activeJobList.append(this);
     _job->start();
index c96164c4bc1ba8381fe4cc3af1b5320820870a90..4de29532d7855d682434c9f9a7d362069fe048ce 100644 (file)
@@ -271,6 +271,7 @@ void PropagateUploadFileNG::startNextChunk()
         QString destination = _propagator->account()->url().path()
             + QLatin1String("/remote.php/dav/files/") + _propagator->account()->user()
             + _propagator->_remoteFolder + _item->_file;
+
         auto headers = PropagateUploadFileCommon::headers();
 
         // "If-Match applies to the source, but we are interested in comparing the etag of the destination
index 15f7a611a93641ae452d67491240d591172ead80..5f10e7035b5a98f8f29ddd34a90d07f1b2018320 100644 (file)
@@ -57,12 +57,11 @@ bool SyncEngine::s_anySyncRunning = false;
 qint64 SyncEngine::minimumFileAgeForUpload = 2000;
 
 SyncEngine::SyncEngine(AccountPtr account, const QString& localPath,
-                       const QUrl& remoteURL, const QString& remotePath, OCC::SyncJournalDb* journal)
+                       const QString& remotePath, OCC::SyncJournalDb* journal)
   : _account(account)
   , _needsUpdate(false)
   , _syncRunning(false)
   , _localPath(localPath)
-  , _remoteUrl(remoteURL)
   , _remotePath(remotePath)
   , _journal(journal)
   , _progressInfo(new ProgressInfo)
@@ -83,18 +82,7 @@ SyncEngine::SyncEngine(AccountPtr account, const QString& localPath,
     // Everything in the SyncEngine expects a trailing slash for the localPath.
     Q_ASSERT(localPath.endsWith(QLatin1Char('/')));
 
-    // We need to reconstruct the url because the path needs to be fully decoded, as csync will re-encode the path:
-    //  Remember that csync will just append the filename to the path and pass it to the vio plugin.
-    //  csync_owncloud will then re-encode everything.
-#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
-    QString url_string = _remoteUrl.scheme() + QLatin1String("://") + _remoteUrl.authority(QUrl::EncodeDelimiters) + _remoteUrl.path(QUrl::FullyDecoded);
-#else
-    // Qt4 was broken anyway as it did not encode the '#' as it should have done  (it was actually a problem when parsing the path from QUrl::setPath
-    QString url_string = _remoteUrl.toString();
-#endif
-    url_string = Utility::toCSyncScheme(url_string);
-
-    csync_create(&_csync_ctx, localPath.toUtf8().data(), url_string.toUtf8().data());
+    csync_create(&_csync_ctx, localPath.toUtf8().data());
     csync_init(_csync_ctx);
     _excludedFiles.reset(new ExcludedFiles(&_csync_ctx->excludes));
     _syncFileStatusTracker.reset(new SyncFileStatusTracker(this));
@@ -831,7 +819,6 @@ void SyncEngine::startSync()
 
     // This is used for the DiscoveryJob to be able to request the main thread/
     // to read in directory contents.
-    qDebug() << Q_FUNC_INFO << _remotePath << _remoteUrl;
     _discoveryMainThread->setupHooks( discoveryJob, _remotePath);
 
     // Starts the update in a seperate thread
@@ -983,7 +970,7 @@ void SyncEngine::slotDiscoveryJobFinished(int discoveryResult)
     _journal->commit("post treewalk");
 
     _propagator = QSharedPointer<OwncloudPropagator>(
-        new OwncloudPropagator (_account, _localPath, _remoteUrl.path(), _remotePath, _journal));
+        new OwncloudPropagator (_account, _localPath, _remotePath, _journal));
     connect(_propagator.data(), SIGNAL(itemCompleted(const SyncFileItem &, const PropagatorJob &)),
             this, SLOT(slotItemCompleted(const SyncFileItem &, const PropagatorJob &)));
     connect(_propagator.data(), SIGNAL(progress(const SyncFileItem &,quint64)),
index ff119d6cbfd986f7e615bba9d6aa4a6f6beb482b..6e4a51ed056b4955a7cf3567ef9ec21c631227f8 100644 (file)
@@ -58,7 +58,7 @@ class OWNCLOUDSYNC_EXPORT SyncEngine : public QObject
     Q_OBJECT
 public:
     SyncEngine(AccountPtr account, const QString &localPath,
-               const QUrl &remoteURL, const QString &remotePath, SyncJournalDb *journal);
+               const QString &remotePath, SyncJournalDb *journal);
     ~SyncEngine();
 
     static QString csyncErrorToString( CSYNC_STATUS);
@@ -196,7 +196,6 @@ private:
     bool _needsUpdate;
     bool _syncRunning;
     QString _localPath;
-    QUrl _remoteUrl;
     QString _remotePath;
     QString _remoteRootEtag;
     SyncJournalDb *_journal;
index 9446ac301623673d674421a05272337c6532d0c2..2a52361637127401fdda33d62ab60ebc19bb1213 100644 (file)
@@ -243,19 +243,6 @@ QString Utility::compactFormatDouble(double value, int prec, const QString& unit
     return str;
 }
 
-QString Utility::toCSyncScheme(const QString &urlStr)
-{
-
-    QUrl url( urlStr );
-    if( url.scheme() == QLatin1String("http") ) {
-        url.setScheme( QLatin1String("owncloud") );
-    } else {
-        // connect SSL!
-        url.setScheme( QLatin1String("ownclouds") );
-    }
-    return url.toString();
-}
-
 QString Utility::escape(const QString &in)
 {
 #if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
index bcca0b2e920b5ea6eba956d4576f7984e37c6ed4..e456f5f5f8074d7db8a1be1e955ef20656813a93 100644 (file)
@@ -44,7 +44,6 @@ namespace Utility
     OWNCLOUDSYNC_EXPORT bool hasLaunchOnStartup(const QString &appName);
     OWNCLOUDSYNC_EXPORT void setLaunchOnStartup(const QString &appName, const QString& guiName, bool launch);
     OWNCLOUDSYNC_EXPORT qint64 freeDiskSpace(const QString &path);
-    OWNCLOUDSYNC_EXPORT QString toCSyncScheme(const QString &urlStr);
 
     /**
      * @brief compactFormatDouble - formats a double value human readable.
index 0f4249c387a2f04b7a5f150c7fe5e7e5c210221c..fefe05ab04d9d496cc70343adb14f6ceeb98df97 100644 (file)
@@ -738,7 +738,7 @@ public:
         _account->setCredentials(new FakeCredentials{_fakeQnam});
 
         _journalDb.reset(new OCC::SyncJournalDb(localPath()));
-        _syncEngine.reset(new OCC::SyncEngine(_account, localPath(), sRootUrl, "", _journalDb.get()));
+        _syncEngine.reset(new OCC::SyncEngine(_account, localPath(), "", _journalDb.get()));
 
         // A new folder will update the local file state database on first sync.
         // To have a state matching what users will encounter, we have to a sync
index cf88acde379d3de346a27b06159164e20755684d..ba524847408a3f57ba0d9274712833a1adc883e5 100644 (file)
@@ -64,14 +64,6 @@ private slots:
         QVERIFY(hasLaunchOnStartup(appName) == false);
     }
 
-    void testToCSyncScheme()
-    {
-        QVERIFY(toCSyncScheme("http://example.com/owncloud/") ==
-                              "owncloud://example.com/owncloud/");
-        QVERIFY(toCSyncScheme("https://example.com/owncloud/") ==
-                              "ownclouds://example.com/owncloud/");
-    }
-
     void testDurationToDescriptiveString()
     {
         QLocale::setDefault(QLocale("C"));