forked from meganz/sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtreeproc.cpp
More file actions
154 lines (136 loc) · 3.07 KB
/
treeproc.cpp
File metadata and controls
154 lines (136 loc) · 3.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
/**
* @file treeproc.cpp
* @brief Node tree processor
*
* (c) 2013-2014 by Mega Limited, Auckland, New Zealand
*
* This file is part of the MEGA SDK - Client Access Engine.
*
* Applications using the MEGA API must present a valid application key
* and comply with the the rules set forth in the Terms of Service.
*
* The MEGA SDK is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
* @copyright Simplified (2-clause) BSD License.
*
* You should have received a copy of the license along with this
* program.
*/
#include "mega/treeproc.h"
#include "mega/megaclient.h"
#include "mega/logging.h"
namespace mega {
// create share keys
TreeProcShareKeys::TreeProcShareKeys(Node* n)
{
sn = n;
}
void TreeProcShareKeys::proc(MegaClient*, Node* n)
{
snk.add(n, sn, sn != NULL);
}
void TreeProcShareKeys::get(Command* c)
{
snk.get(c);
}
void TreeProcForeignKeys::proc(MegaClient* client, Node* n)
{
if (n->foreignkey)
{
client->nodekeyrewrite.push_back(n->nodehandle);
n->foreignkey = false;
}
}
// total disk space / node count
TreeProcDU::TreeProcDU()
{
numbytes = 0;
numfiles = 0;
numfolders = 0;
}
void TreeProcDU::proc(MegaClient*, Node* n)
{
if (n->type == FILENODE)
{
numbytes += n->size;
numfiles++;
}
else
{
numfolders++;
}
}
// mark node as removed and notify
void TreeProcDel::proc(MegaClient* client, Node* n)
{
n->changed.removed = true;
n->tag = client->reqtag;
client->notifynode(n);
if (n->owner != client->me)
{
client->useralerts.noteSharedNode(n->owner, n->type, 0, NULL);
}
}
void TreeProcApplyKey::proc(MegaClient *client, Node *n)
{
if (n->attrstring)
{
n->applykey();
if (!n->attrstring)
{
n->changed.attrs = true;
client->notifynode(n);
}
}
}
#ifdef ENABLE_SYNC
// stop sync get
void TreeProcDelSyncGet::proc(MegaClient*, Node* n)
{
if (n->syncget)
{
delete n->syncget;
n->syncget = NULL;
}
}
LocalTreeProcMove::LocalTreeProcMove(Sync* sync, bool recreate)
{
this->newsync = sync;
this->recreate = recreate;
nc = 0;
}
void LocalTreeProcMove::proc(MegaClient*, LocalNode* localnode)
{
if (newsync != localnode->sync)
{
localnode->sync->statecachedel(localnode);
localnode->sync = newsync;
newsync->statecacheadd(localnode);
}
if (recreate)
{
localnode->created = false;
localnode->node = NULL;
}
nc++;
}
void LocalTreeProcUpdateTransfers::proc(MegaClient *, LocalNode *localnode)
{
if (localnode->transfer && !localnode->transfer->localfilename.empty())
{
LOG_debug << "Updating transfer path";
localnode->prepare();
}
}
void LocalTreeProcUnlinkNodes::proc(MegaClient *, LocalNode *localnode)
{
if (localnode->node)
{
localnode->node->localnode = NULL;
localnode->node = NULL;
}
}
#endif
} // namespace