Make sure moves involving e2e are delete + upload
authorKevin Ottens <kevin.ottens@nextcloud.com>
Thu, 2 Jul 2020 16:19:16 +0000 (18:19 +0200)
committerKevin Ottens (Rebase PR Action) <er-vin@users.noreply.github.com>
Mon, 6 Jul 2020 05:27:14 +0000 (05:27 +0000)
If the file has a mangled name or will end up in a parent directory
known to be encrypted, we stick to the CSYNC_INTRUCTION_NEW instead of
going for CSYNC_INSTRUCTION_RENAME. This way we'll have a delete and an
upload instead of a move command.

Signed-off-by: Kevin Ottens <kevin.ottens@nextcloud.com>
src/csync/csync_reconcile.cpp

index 8b947c65197ba5957fc97934dc0eb79dc1b72275..7b664addddd294c8fba1f4aaf906a2b2c50d7539 100644 (file)
@@ -178,9 +178,22 @@ static void _csync_merge_algorithm_visitor(csync_file_stat_t *cur, CSYNC * ctx)
                         basePath.constData(), other ? "found" : "not found");
                 }
 
+                const auto curParentPath = [=]{
+                    const auto slashPosition = cur->path.lastIndexOf('/');
+                    if (slashPosition >= 0) {
+                        return cur->path.left(slashPosition);
+                    } else {
+                        return QByteArray();
+                    }
+                }();
+                auto curParent = our_tree->findFile(curParentPath);
+
                 if(!other) {
                     // Stick with the NEW
                     return;
+                } else if (!other->e2eMangledName.isEmpty() || (curParent && curParent->isE2eEncrypted)) {
+                    // Stick with the NEW as well, we want to always issue delete + upload in such cases
+                    return;
                 } else if (other->instruction == CSYNC_INSTRUCTION_RENAME) {
                     // Some other EVAL_RENAME already claimed other.
                     // We do nothing: maybe a different candidate for