15
15
#include " sharemanager.h"
16
16
#include " ocssharejob.h"
17
17
#include " account.h"
18
+ #include " folderman.h"
19
+ #include " accountstate.h"
18
20
19
21
#include < QUrl>
20
22
#include < QJsonDocument>
23
25
24
26
namespace OCC {
25
27
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
+
26
53
Share::Share (AccountPtr account,
27
54
const QString &id,
28
55
const QString &path,
@@ -43,6 +70,11 @@ AccountPtr Share::account() const
43
70
return _account;
44
71
}
45
72
73
+ QString Share::path () const
74
+ {
75
+ return _path;
76
+ }
77
+
46
78
QString Share::getId () const
47
79
{
48
80
return _id;
@@ -88,6 +120,8 @@ void Share::deleteShare()
88
120
void Share::slotDeleted ()
89
121
{
90
122
emit shareDeleted ();
123
+
124
+ updateFolder (_account, _path);
91
125
}
92
126
93
127
void Share::slotOcsError (int statusCode, const QString &message)
@@ -247,6 +281,8 @@ void ShareManager::slotLinkShareCreated(const QJsonDocument &reply)
247
281
QSharedPointer<LinkShare> share (parseLinkShare (data));
248
282
249
283
emit linkShareCreated (share);
284
+
285
+ updateFolder (_account, share->path ());
250
286
}
251
287
252
288
@@ -292,6 +328,8 @@ void ShareManager::slotShareCreated(const QJsonDocument &reply)
292
328
QSharedPointer<Share> share (parseShare (data));
293
329
294
330
emit shareCreated (share);
331
+
332
+ updateFolder (_account, share->path ());
295
333
}
296
334
297
335
void ShareManager::fetchShares (const QString &path)
0 commit comments