Skip to content

Commit c36043a

Browse files
committedOct 24, 2017
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
1 parent ee63b36 commit c36043a

File tree

2 files changed

+40
-0
lines changed

2 files changed

+40
-0
lines changed
 

‎src/gui/sharemanager.cpp

+38
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
#include "sharemanager.h"
1616
#include "ocssharejob.h"
1717
#include "account.h"
18+
#include "folderman.h"
19+
#include "accountstate.h"
1820

1921
#include <QUrl>
2022
#include <QJsonDocument>
@@ -23,6 +25,31 @@
2325

2426
namespace OCC {
2527

28+
/**
29+
* When a share is modified, we need to tell the folders so they can adjust overlay icons
30+
*/
31+
static void updateFolder(const AccountPtr &account, const QString &path)
32+
{
33+
foreach (Folder *f, FolderMan::instance()->map()) {
34+
if (f->accountState()->account() != account)
35+
continue;
36+
auto folderPath = f->remotePath();
37+
if (path.startsWith(folderPath) && (path == folderPath || folderPath.endsWith('/') || path[folderPath.size()] == '/')) {
38+
// Workaround the fact that the server does not invalidate the etags of parent directories
39+
// when something is shared.
40+
auto relative = path.midRef(folderPath.size());
41+
if (relative.startsWith('/'))
42+
relative = relative.mid(1);
43+
f->journalDb()->avoidReadFromDbOnNextSync(relative.toString());
44+
45+
// Schedule a sync so it can update the remote permission flag and let the socket API
46+
// know about the shared icon.
47+
f->scheduleThisFolderSoon();
48+
}
49+
}
50+
}
51+
52+
2653
Share::Share(AccountPtr account,
2754
const QString &id,
2855
const QString &path,
@@ -43,6 +70,11 @@ AccountPtr Share::account() const
4370
return _account;
4471
}
4572

73+
QString Share::path() const
74+
{
75+
return _path;
76+
}
77+
4678
QString Share::getId() const
4779
{
4880
return _id;
@@ -88,6 +120,8 @@ void Share::deleteShare()
88120
void Share::slotDeleted()
89121
{
90122
emit shareDeleted();
123+
124+
updateFolder(_account, _path);
91125
}
92126

93127
void Share::slotOcsError(int statusCode, const QString &message)
@@ -247,6 +281,8 @@ void ShareManager::slotLinkShareCreated(const QJsonDocument &reply)
247281
QSharedPointer<LinkShare> share(parseLinkShare(data));
248282

249283
emit linkShareCreated(share);
284+
285+
updateFolder(_account, share->path());
250286
}
251287

252288

@@ -292,6 +328,8 @@ void ShareManager::slotShareCreated(const QJsonDocument &reply)
292328
QSharedPointer<Share> share(parseShare(data));
293329

294330
emit shareCreated(share);
331+
332+
updateFolder(_account, share->path());
295333
}
296334

297335
void ShareManager::fetchShares(const QString &path)

‎src/gui/sharemanager.h

+2
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ class Share : public QObject
6464
*/
6565
AccountPtr account() const;
6666

67+
QString path() const;
68+
6769
/*
6870
* Get the id
6971
*/

0 commit comments

Comments
 (0)
Please sign in to comment.