diff options
author | alex-z <blackslayer4@gmail.com> | 2022-02-10 17:14:51 +0300 |
---|---|---|
committer | alex-z <blackslayer4@gmail.com> | 2022-02-10 17:14:51 +0300 |
commit | c557add79e5242ea2b60dc5eda1f72526e709a3d (patch) | |
tree | 04cdb3d34bbc062187abe57f6c03929df26e1b5c | |
parent | 2964136cae6af3d2809ef6dbd3c3ee07c7ee82a7 (diff) |
Do not remove folders with pending upload files.bugfix/do-not-remove-folder-with-pending-upload-files
Signed-off-by: alex-z <blackslayer4@gmail.com>
-rw-r--r-- | src/gui/sharedialog.cpp | 2 | ||||
-rw-r--r-- | src/libsync/owncloudpropagator.cpp | 34 |
2 files changed, 36 insertions, 0 deletions
diff --git a/src/gui/sharedialog.cpp b/src/gui/sharedialog.cpp index 6e48b70be..246357329 100644 --- a/src/gui/sharedialog.cpp +++ b/src/gui/sharedialog.cpp @@ -385,6 +385,8 @@ void ShareDialog::slotLinkShareRequiresPassword(const QString &message) passwordInputDialog->setAttribute(Qt::WA_DeleteOnClose); passwordInputDialog->open(); + const QString &connection = {}; + connect(passwordInputDialog, &QDialog::finished, this, [this, passwordInputDialog](const int result) { if (result == QDialog::Accepted && _manager) { // Try to create the link share again with the newly entered password diff --git a/src/libsync/owncloudpropagator.cpp b/src/libsync/owncloudpropagator.cpp index c55597646..e2d3832f9 100644 --- a/src/libsync/owncloudpropagator.cpp +++ b/src/libsync/owncloudpropagator.cpp @@ -423,6 +423,40 @@ void OwncloudPropagator::start(SyncFileItemVector &&items) { Q_ASSERT(std::is_sorted(items.begin(), items.end())); + SyncFileItemVector dirsToRemove; + for (const SyncFileItemPtr &item : items) { + if (item->isDirectory() && item->_instruction == CSYNC_INSTRUCTION_REMOVE) { + dirsToRemove.push_back(item); + } + } + + for (const SyncFileItemPtr &dirToRemove : dirsToRemove) { + auto itFoundFileToUpload = + std::find_if(std::cbegin(items), std::cend(items), [&dirToRemove, this](const SyncFileItemPtr &item) { + if ((item->_type == ItemTypeFile || item->_type == ItemTypeVirtualFile) + && item->_instruction == CSYNC_INSTRUCTION_NEW && item->_file.startsWith(dirToRemove->_file)) { + // should be either new file or new hydrated placeholder (TODO: not sure if this is a correct conditon, needs to be checked) + return item->_type == ItemTypeFile || syncOptions()._vfs.data() && !syncOptions()._vfs->isDehydratedPlaceholder(fullLocalPath(item->_file)); + } + }); + + if (itFoundFileToUpload != std::cend(items)) { + const auto dirToRemoveFile = dirToRemove->_file; + auto foundDirToRemove = std::find_if(std::cbegin(items), std::cend(items), [&dirToRemoveFile](const SyncFileItemPtr &item) { + return item->isDirectory() && item->_instruction == CSYNC_INSTRUCTION_REMOVE && item->_file == dirToRemoveFile; + }); + + if (foundDirToRemove != std::cend(items)) { + items.erase(std::remove_if(items.begin(), items.end(), + [&dirToRemoveFile](const SyncFileItemPtr &item) { + return item->isDirectory() && item->_instruction == CSYNC_INSTRUCTION_REMOVE + && item->_file == dirToRemoveFile; + }), + items.end()); + } + } + } + /* This builds all the jobs needed for the propagation. * Each directory is a PropagateDirectory job, which contains the files in it. * In order to do that we loop over the items. (which are sorted by destination) |