diff options
author | Olivier Goffart <ogoffart@woboq.com> | 2017-10-23 20:08:46 +0300 |
---|---|---|
committer | Olivier Goffart <olivier@woboq.com> | 2017-10-24 16:50:14 +0300 |
commit | c36043a175b33fd957ff5c8b97f6eb58f8f3ab3a (patch) | |
tree | 80154af6ad3f8ba4ebeb23f741f22fdf7294000f /src/gui/sharemanager.cpp | |
parent | ee63b36ed366fee84ae4d8b72dac91e1c7db7146 (diff) |
ShareDialog: trigger a sync for folder affected by a change of sharing
This allow the sync engine to query the new metadata and update the
overlay icons.
Note: we also need to invalidate the etags because the server does not
change the etag of parent directories that see their share-types changed.
Issue #6098
Diffstat (limited to 'src/gui/sharemanager.cpp')
-rw-r--r-- | src/gui/sharemanager.cpp | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/src/gui/sharemanager.cpp b/src/gui/sharemanager.cpp index 4ff75d3c5..9901b47cf 100644 --- a/src/gui/sharemanager.cpp +++ b/src/gui/sharemanager.cpp @@ -15,6 +15,8 @@ #include "sharemanager.h" #include "ocssharejob.h" #include "account.h" +#include "folderman.h" +#include "accountstate.h" #include <QUrl> #include <QJsonDocument> @@ -23,6 +25,31 @@ namespace OCC { +/** + * When a share is modified, we need to tell the folders so they can adjust overlay icons + */ +static void updateFolder(const AccountPtr &account, const QString &path) +{ + foreach (Folder *f, FolderMan::instance()->map()) { + if (f->accountState()->account() != account) + continue; + auto folderPath = f->remotePath(); + if (path.startsWith(folderPath) && (path == folderPath || folderPath.endsWith('/') || path[folderPath.size()] == '/')) { + // Workaround the fact that the server does not invalidate the etags of parent directories + // when something is shared. + auto relative = path.midRef(folderPath.size()); + if (relative.startsWith('/')) + relative = relative.mid(1); + f->journalDb()->avoidReadFromDbOnNextSync(relative.toString()); + + // Schedule a sync so it can update the remote permission flag and let the socket API + // know about the shared icon. + f->scheduleThisFolderSoon(); + } + } +} + + Share::Share(AccountPtr account, const QString &id, const QString &path, @@ -43,6 +70,11 @@ AccountPtr Share::account() const return _account; } +QString Share::path() const +{ + return _path; +} + QString Share::getId() const { return _id; @@ -88,6 +120,8 @@ void Share::deleteShare() void Share::slotDeleted() { emit shareDeleted(); + + updateFolder(_account, _path); } void Share::slotOcsError(int statusCode, const QString &message) @@ -247,6 +281,8 @@ void ShareManager::slotLinkShareCreated(const QJsonDocument &reply) QSharedPointer<LinkShare> share(parseLinkShare(data)); emit linkShareCreated(share); + + updateFolder(_account, share->path()); } @@ -292,6 +328,8 @@ void ShareManager::slotShareCreated(const QJsonDocument &reply) QSharedPointer<Share> share(parseShare(data)); emit shareCreated(share); + + updateFolder(_account, share->path()); } void ShareManager::fetchShares(const QString &path) |