Compare commits
1027
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ba5ca3d6be | ||
|
|
7294a74de0 | ||
|
|
ce9fcb5b0a | ||
|
|
d26bce0dea | ||
|
|
0cb7ae1100 | ||
|
|
235a365ade | ||
|
|
6efde25562 | ||
|
|
6676480e1d | ||
|
|
da0e4f148a | ||
|
|
f3c9c64bce | ||
|
|
75a44c4281 | ||
|
|
4cb88b2bfb | ||
|
|
e9c6f95991 | ||
|
|
46de85a7f8 | ||
|
|
1d29aba45e | ||
|
|
6ec030942f | ||
|
|
cadd63d458 | ||
|
|
2be7753ed9 | ||
|
|
854913a22b | ||
|
|
bf44f1b24f | ||
|
|
4b330e8b2d | ||
|
|
b0f3fec939 | ||
|
|
cc70180db2 | ||
|
|
5082a10a18 | ||
|
|
9216896777 | ||
|
|
84283a0441 | ||
|
|
6eb08ca438 | ||
|
|
d85e318553 | ||
|
|
63c797d35b | ||
|
|
e684088ca4 | ||
|
|
f0c4ae3f5e | ||
|
|
9aef76be8f | ||
|
|
443ab3c24b | ||
|
|
a57fb52b63 | ||
|
|
e94e2bcf45 | ||
|
|
5c954d1bdd | ||
|
|
5d13fb6a6e | ||
|
|
e896a88d29 | ||
|
|
7979c48ca3 | ||
|
|
2894b8ef66 | ||
|
|
6f42dc2f7a | ||
|
|
25f90d5f5f | ||
|
|
4c71a9a1c4 | ||
|
|
e79d319925 | ||
|
|
ed16abcede | ||
|
|
3edda33db6 | ||
|
|
aeaad8ab35 | ||
|
|
34865d0e68 | ||
|
|
9acec773fa | ||
|
|
73201843e5 | ||
|
|
58f3c4ef8c | ||
|
|
99bad9ce9d | ||
|
|
fd65e61127 | ||
|
|
d2805a077d | ||
|
|
8fc1f03f54 | ||
|
|
678ec256bf | ||
|
|
125d8b4626 | ||
|
|
b4b1e0b340 | ||
|
|
84859a8796 | ||
|
|
3f0118eb0d | ||
|
|
adb800d56a | ||
|
|
19127c9c64 | ||
|
|
7348f39eff | ||
|
|
cc24e38081 | ||
|
|
d3c9fef7b4 | ||
|
|
f014209d75 | ||
|
|
813d6e339c | ||
|
|
5426e968d9 | ||
|
|
649e8fe538 | ||
|
|
73ee67c5c0 | ||
|
|
673925df84 | ||
|
|
e101389af0 | ||
|
|
f7cc1f4b5d | ||
|
|
b97721f729 | ||
|
|
803500ee34 | ||
|
|
1dc05faf58 | ||
|
|
eb8f760370 | ||
|
|
cae5578cc5 | ||
|
|
caa63463d1 | ||
|
|
022893dbc9 | ||
|
|
950b41f72b | ||
|
|
77ad931cc3 | ||
|
|
4d36015a31 | ||
|
|
9d95d57788 | ||
|
|
4178b3ed0e | ||
|
|
55878490e9 | ||
|
|
aab53579e0 | ||
|
|
c37e039360 | ||
|
|
752294e4ea | ||
|
|
8fdd7b5f3d | ||
|
|
d71a47692f | ||
|
|
031afe69bb | ||
|
|
8cae38c0ae | ||
|
|
c77b9620c6 | ||
|
|
0865ed5374 | ||
|
|
7d0507e650 | ||
|
|
5af3bc7b2d | ||
|
|
ee8aeabf05 | ||
|
|
e7faa2ee3c | ||
|
|
c843b27b19 | ||
|
|
295a88c8c6 | ||
|
|
72306e6a40 | ||
|
|
86ac8e0d75 | ||
|
|
9cee18c834 | ||
|
|
85997631ff | ||
|
|
73a919ff96 | ||
|
|
c8c3380a8f | ||
|
|
e9d1de7781 | ||
|
|
357f1c935d | ||
|
|
7258df1c2d | ||
|
|
13df75d0e0 | ||
|
|
20a4d85836 | ||
|
|
6af4238664 | ||
|
|
2c73e1947d | ||
|
|
cc8c9cb0a5 | ||
|
|
c66b570396 | ||
|
|
ad1bea2a6a | ||
|
|
cad467dede | ||
|
|
a4b3430d6e | ||
|
|
de28c1e3f8 | ||
|
|
7135b436ca | ||
|
|
bb3d1b1d7e | ||
|
|
254fcd5ea8 | ||
|
|
fb4455e16a | ||
|
|
19fd4e3a56 | ||
|
|
274a83a039 | ||
|
|
5cabb4fbc3 | ||
|
|
4b19d06415 | ||
|
|
f472fd83c4 | ||
|
|
178159b0c5 | ||
|
|
a8ef63eca0 | ||
|
|
13f30aa60f | ||
|
|
f4bc677d02 | ||
|
|
6d70bc3786 | ||
|
|
b62ad57988 | ||
|
|
f074a1fa53 | ||
|
|
6e1c5aab91 | ||
|
|
9679bb3bf3 | ||
|
|
eec2b842bc | ||
|
|
2225aca40f | ||
|
|
3d017d1e0c | ||
|
|
503c4f339f | ||
|
|
cdfb88d6a8 | ||
|
|
58cc732f3a | ||
|
|
2d977ed535 | ||
|
|
0243ec0fca | ||
|
|
ee0f62410f | ||
|
|
3809b20d50 | ||
|
|
067bf797dd | ||
|
|
98931433a5 | ||
|
|
d9868c55c2 | ||
|
|
fd5bd0b099 | ||
|
|
5baa6dc856 | ||
|
|
2273c94cf4 | ||
|
|
d9cf1feaee | ||
|
|
cc48cf88f3 | ||
|
|
33c9a25665 | ||
|
|
add25062f3 | ||
|
|
18240ea5ef | ||
|
|
d20f5fc2b3 | ||
|
|
afae514535 | ||
|
|
fa24020ab1 | ||
|
|
f34bc4061b | ||
|
|
8f4a39ebe9 | ||
|
|
da1a69932a | ||
|
|
207553f638 | ||
|
|
af2026fac8 | ||
|
|
2f21006457 | ||
|
|
eed0458794 | ||
|
|
42200fddcd | ||
|
|
6ce4c67ac1 | ||
|
|
a523641dff | ||
|
|
b3b1afa307 | ||
|
|
0a1dc26a95 | ||
|
|
afad73fe8b | ||
|
|
935a95c247 | ||
|
|
fdb1a59524 | ||
|
|
22a597389d | ||
|
|
49248b02b3 | ||
|
|
feba2c67d4 | ||
|
|
305c509fc6 | ||
|
|
ed1b597fc5 | ||
|
|
2691da66f7 | ||
|
|
417b203b09 | ||
|
|
0746526170 | ||
|
|
829159690f | ||
|
|
41362cdde6 | ||
|
|
5f5aefef53 | ||
|
|
accf68fc60 | ||
|
|
06b6ca22c0 | ||
|
|
5ec53522fe | ||
|
|
e568f899aa | ||
|
|
1a01f361ad | ||
|
|
86dcc83461 | ||
|
|
5de8af82bb | ||
|
|
25b0695d3e | ||
|
|
a2efcafb3e | ||
|
|
6b2667d4dc | ||
|
|
1fbf87995b | ||
|
|
981378c2e3 | ||
|
|
67ca417cb8 | ||
|
|
df9a5f11ae | ||
|
|
ec0d8a0c07 | ||
|
|
bb86e5b7e5 | ||
|
|
a97efd2a5b | ||
|
|
01e170ba69 | ||
|
|
7d39332a79 | ||
|
|
19930e6252 | ||
|
|
ea74562290 | ||
|
|
74f39239c6 | ||
|
|
067ad8cf16 | ||
|
|
0c79741216 | ||
|
|
94f28430a3 | ||
|
|
83476a9e84 | ||
|
|
43a35f4878 | ||
|
|
ca2ea8cef9 | ||
|
|
63ba0a9fab | ||
|
|
4fb34fcb7c | ||
|
|
9836caf2cb | ||
|
|
65496d247f | ||
|
|
07c6e8000c | ||
|
|
4687b1f805 | ||
|
|
7adae54f87 | ||
|
|
f5baccaf08 | ||
|
|
589f885b63 | ||
|
|
52278f02f4 | ||
|
|
0d40838196 | ||
|
|
3693218fc5 | ||
|
|
d4c19f790d | ||
|
|
bc7a1754ad | ||
|
|
f95374bb3e | ||
|
|
848556200b | ||
|
|
e043c84cae | ||
|
|
0314ea1103 | ||
|
|
6a1c3d27f8 | ||
|
|
d22d8f4f25 | ||
|
|
61cd658ab0 | ||
|
|
998f631ee8 | ||
|
|
bee7146a60 | ||
|
|
a497e129c4 | ||
|
|
e1f6dad499 | ||
|
|
58f01da459 | ||
|
|
3895dc8e14 | ||
|
|
3ea11abb56 | ||
|
|
6524762c09 | ||
|
|
70682ff397 | ||
|
|
b37dec42a2 | ||
|
|
3f48831e8b | ||
|
|
cda401356d | ||
|
|
897c50e8e6 | ||
|
|
5218eea8ad | ||
|
|
6e5d044251 | ||
|
|
fcb936bca9 | ||
|
|
1837d89ef9 | ||
|
|
9979a820d3 | ||
|
|
1ed8f162ae | ||
|
|
31b3fed274 | ||
|
|
3758e9cdf3 | ||
|
|
eae4f0a57d | ||
|
|
00c344112e | ||
|
|
6c17d380b7 | ||
|
|
e6352f74ad | ||
|
|
3f95941045 | ||
|
|
c42c4415bf | ||
|
|
cd8dd7a869 | ||
|
|
fef3c7f937 | ||
|
|
4212138546 | ||
|
|
61859bbb09 | ||
|
|
5906091051 | ||
|
|
51a956fd84 | ||
|
|
cd5a4abc87 | ||
|
|
2dd2b309df | ||
|
|
cf80cdbe7d | ||
|
|
74b0269230 | ||
|
|
679b068dfa | ||
|
|
aea36229fb | ||
|
|
67d97c26ec | ||
|
|
0c200ba323 | ||
|
|
be253bb01b | ||
|
|
8d25922f27 | ||
|
|
4ff0d9d42a | ||
|
|
24cc345fbb | ||
|
|
0ababcf913 | ||
|
|
c5b47abf8a | ||
|
|
7960297ea2 | ||
|
|
3cd292db5b | ||
|
|
c708fbd984 | ||
|
|
f5f960bd81 | ||
|
|
2a76b81a32 | ||
|
|
43e4c121ee | ||
|
|
6765150ba9 | ||
|
|
ab14cc9b6d | ||
|
|
64d9689be5 | ||
|
|
904224447f | ||
|
|
47be32c804 | ||
|
|
98bbdc2e4e | ||
|
|
7da3553db3 | ||
|
|
c37c7ba874 | ||
|
|
def3d7cdd5 | ||
|
|
1565f7e509 | ||
|
|
75d503b94c | ||
|
|
63833eb650 | ||
|
|
7cce8baca6 | ||
|
|
59e18ca68c | ||
|
|
030a7d61ba | ||
|
|
40ee06560e | ||
|
|
4ce9ffdf5a | ||
|
|
b3e63984bb | ||
|
|
96f399293d | ||
|
|
49b738fb3c | ||
|
|
5b93739487 | ||
|
|
38a74fd195 | ||
|
|
ea9d101622 | ||
|
|
ea80f4591b | ||
|
|
f2d729022d | ||
|
|
94d33f2c4a | ||
|
|
20768266ca | ||
|
|
1db0e731e0 | ||
|
|
4d356318f0 | ||
|
|
cd82b41cf1 | ||
|
|
3b837b4b6b | ||
|
|
189922e534 | ||
|
|
4cde54bdb3 | ||
|
|
00dc0bcca6 | ||
|
|
047bd1c379 | ||
|
|
ce0a60df67 | ||
|
|
95b7927a4c | ||
|
|
e6d15c6a72 | ||
|
|
0175ffeb3f | ||
|
|
92f22d04b0 | ||
|
|
55ad2a536b | ||
|
|
18451bd4fe | ||
|
|
b34136ce06 | ||
|
|
0f89b5a4f5 | ||
|
|
004c8b7f38 | ||
|
|
4c00dba1cf | ||
|
|
2fe9f8c295 | ||
|
|
e8a7ad7476 | ||
|
|
0601685040 | ||
|
|
adec5fa746 | ||
|
|
f6d3a85a7f | ||
|
|
0eaf9094a1 | ||
|
|
20320f81c3 | ||
|
|
cbee800509 | ||
|
|
d9baeab63e | ||
|
|
7ef55b3c46 | ||
|
|
6b5b3d2b6b | ||
|
|
2d2ad9ee43 | ||
|
|
b2140f3c30 | ||
|
|
d3108b5e6c | ||
|
|
e35c5eb5c7 | ||
|
|
a4d26ab82d | ||
|
|
d3362ba85e | ||
|
|
9bb42a2906 | ||
|
|
9c696ad96a | ||
|
|
f2ff10e3f7 | ||
|
|
0f2a0eec8e | ||
|
|
9289bb424a | ||
|
|
859323c5ca | ||
|
|
61b0a24b28 | ||
|
|
8624b672e2 | ||
|
|
163c0e4058 | ||
|
|
27b1c948e9 | ||
|
|
ea48365d2f | ||
|
|
a193906d94 | ||
|
|
fad981daee | ||
|
|
2da9f84907 | ||
|
|
9ba0620cab | ||
|
|
cc2a98bbad | ||
|
|
75c660916d | ||
|
|
d2a19d21fe | ||
|
|
6d2178dfc9 | ||
|
|
3fcbe3aba9 | ||
|
|
3630744086 | ||
|
|
f4c6679b0e | ||
|
|
aff2ecbca0 | ||
|
|
38f831ab6b | ||
|
|
8ff7cc9e16 | ||
|
|
2ef1970479 | ||
|
|
4cdbecd705 | ||
|
|
0b977c2e1c | ||
|
|
25a51b2cc8 | ||
|
|
1e9960752f | ||
|
|
22ee12e28c | ||
|
|
86aadf9d6c | ||
|
|
c8f6e39199 | ||
|
|
48e55d4827 | ||
|
|
73762e460a | ||
|
|
d04d1f3a3b | ||
|
|
9dc3c807fb | ||
|
|
78067eaa4c | ||
|
|
b2578a19ba | ||
|
|
06bb0f7496 | ||
|
|
e1565f60d6 | ||
|
|
c6910bc2fe | ||
|
|
dccb5a9826 | ||
|
|
8f1cba3770 | ||
|
|
44ffc39729 | ||
|
|
d7a888c1fd | ||
|
|
b78cf2c710 | ||
|
|
92bb1ce576 | ||
|
|
bf56f338f2 | ||
|
|
82b398ff7f | ||
|
|
6cb696d508 | ||
|
|
dffb418e60 | ||
|
|
348b94a554 | ||
|
|
60b2c99660 | ||
|
|
ddd20ae5b5 | ||
|
|
ed615379c4 | ||
|
|
09aee68bd7 | ||
|
|
7174e0e081 | ||
|
|
ebe05db662 | ||
|
|
64e5479ca0 | ||
|
|
7fdd4f215e | ||
|
|
79d81662ce | ||
|
|
330c97ab30 | ||
|
|
c1bf0e12cc | ||
|
|
a5f01265d6 | ||
|
|
9b9c278718 | ||
|
|
e7ee5dd864 | ||
|
|
d466d40cf0 | ||
|
|
0acc14144a | ||
|
|
41f66edfb9 | ||
|
|
9c41451986 | ||
|
|
fb4e2b1fc9 | ||
|
|
ea5856c4b0 | ||
|
|
cf464ef25f | ||
|
|
bded394761 | ||
|
|
ef1155743e | ||
|
|
4ff4c5950d | ||
|
|
8e1053a116 | ||
|
|
576cef2d53 | ||
|
|
5e23680b36 | ||
|
|
4e7c3840ac | ||
|
|
265b64b6f0 | ||
|
|
3bd8c92f51 | ||
|
|
a51f26c785 | ||
|
|
af753ec392 | ||
|
|
8de24af4b9 | ||
|
|
790be1b02b | ||
|
|
a093e1c9f0 | ||
|
|
3381a84dec | ||
|
|
42913d3d18 | ||
|
|
b84dfc595f | ||
|
|
b6be4e8975 | ||
|
|
25a52f41b8 | ||
|
|
18bc3314fe | ||
|
|
4c4abc9266 | ||
|
|
8cf6ad560e | ||
|
|
059f0ca636 | ||
|
|
4cb79eeab9 | ||
|
|
9f0c7f4711 | ||
|
|
cfbae15999 | ||
|
|
a7a54bcc8b | ||
|
|
1eed7e5050 | ||
|
|
d21dd91a77 | ||
|
|
c792ff1fcb | ||
|
|
ec96ecafcc | ||
|
|
b875c504a0 | ||
|
|
1bb707f0a2 | ||
|
|
28dd15e07e | ||
|
|
0fb8ec2b7c | ||
|
|
ca1ebaaf14 | ||
|
|
7f165dd6f8 | ||
|
|
abe4603639 | ||
|
|
da61fec0a0 | ||
|
|
39bffdab9c | ||
|
|
c12bb0f081 | ||
|
|
96896d3060 | ||
|
|
d158b98b35 | ||
|
|
57eb691b53 | ||
|
|
fe8f8c43f5 | ||
|
|
39f79e03ce | ||
|
|
a9c564777a | ||
|
|
876f94ef4e | ||
|
|
3bc23edfd3 | ||
|
|
88cc804d01 | ||
|
|
993403bf76 | ||
|
|
35e58ae20f | ||
|
|
27b6f754b5 | ||
|
|
4186e30912 | ||
|
|
9205f414cc | ||
|
|
d986290db8 | ||
|
|
dcae5da0ec | ||
|
|
bcc0aa8fd6 | ||
|
|
8c36953790 | ||
|
|
18bc40a531 | ||
|
|
da74f45d46 | ||
|
|
527d104ba7 | ||
|
|
7e41284cc8 | ||
|
|
071d85cd22 | ||
|
|
d0ac577686 | ||
|
|
0dd992b7a6 | ||
|
|
2f95c66360 | ||
|
|
c7254ed8be | ||
|
|
bb25dd0ea1 | ||
|
|
c565071dad | ||
|
|
b96654dd14 | ||
|
|
048406edfd | ||
|
|
62c4e80c36 | ||
|
|
b3194da23c | ||
|
|
207e2dce52 | ||
|
|
dfd2b0e8b9 | ||
|
|
248a112236 | ||
|
|
dbfc62eef5 | ||
|
|
b8b4f937d4 | ||
|
|
f79d7f8eb4 | ||
|
|
c88b31ca2f | ||
|
|
4c5cb61802 | ||
|
|
90f0d0bb37 | ||
|
|
71cfefe6fa | ||
|
|
4aa8c9ac09 | ||
|
|
6bb542ca09 | ||
|
|
f9c65bf8e1 | ||
|
|
411a67c31f | ||
|
|
02e92a0db0 | ||
|
|
9b59e6029d | ||
|
|
ac84febce9 | ||
|
|
e57ef72be1 | ||
|
|
2d605ca694 | ||
|
|
c64f732878 | ||
|
|
40f8fb503a | ||
|
|
987bd0154f | ||
|
|
8680c24329 | ||
|
|
1a2ceb6e2b | ||
|
|
8d8aff2680 | ||
|
|
397252d97a | ||
|
|
58389432d7 | ||
|
|
a55306aa27 | ||
|
|
e44bcfedaf | ||
|
|
33a2b5cc84 | ||
|
|
a855f02f63 | ||
|
|
8eafaa266d | ||
|
|
b5dc56d72c | ||
|
|
a103c960a4 | ||
|
|
98b8584efc | ||
|
|
fa076ee83f | ||
|
|
d4b90e5202 | ||
|
|
84b21c62c5 | ||
|
|
caec31dd7f | ||
|
|
f86337ffc8 | ||
|
|
70163c3aaf | ||
|
|
5b98550349 | ||
|
|
0a24886ce6 | ||
|
|
9da4e0e7e9 | ||
|
|
d35d5c9437 | ||
|
|
ac018be8b1 | ||
|
|
6fb720e0ea | ||
|
|
e736ff313f | ||
|
|
f696d774bb | ||
|
|
50dcc735c7 | ||
|
|
3c30f72cd5 | ||
|
|
874d5bbca0 | ||
|
|
acf21c7d54 | ||
|
|
b7d4c27920 | ||
|
|
555ff804fe | ||
|
|
ec900d6e9d | ||
|
|
0b27fe7642 | ||
|
|
ad8055635d | ||
|
|
f4a27fb1d3 | ||
|
|
b0b75ac8ea | ||
|
|
108900e88a | ||
|
|
439182cdfa | ||
|
|
9b0aba1339 | ||
|
|
b3024740d0 | ||
|
|
cfd2ea8ece | ||
|
|
d0adbf5026 | ||
|
|
9d6e0886f4 | ||
|
|
f1d1a26b64 | ||
|
|
15ccf29f0b | ||
|
|
ad87d5e545 | ||
|
|
322a8d144a | ||
|
|
4aa9ce1a27 | ||
|
|
364ec32a39 | ||
|
|
6444042a02 | ||
|
|
5df4f13938 | ||
|
|
4eba413631 | ||
|
|
060c14792c | ||
|
|
a43d25841d | ||
|
|
da0398c103 | ||
|
|
3b320087f3 | ||
|
|
0c85336e82 | ||
|
|
367bd1978d | ||
|
|
8a6a5a6bc1 | ||
|
|
c064f89988 | ||
|
|
c36fe14272 | ||
|
|
8a19ea8dcb | ||
|
|
d0a4b05706 | ||
|
|
38e055ed12 | ||
|
|
0924413056 | ||
|
|
09acec0d11 | ||
|
|
fa8ac48c2a | ||
|
|
da70f7b78c | ||
|
|
e0c1e6f19d | ||
|
|
b71360ec01 | ||
|
|
3807d8e6ef | ||
|
|
d7cce3c9fb | ||
|
|
5eaa3bfe44 | ||
|
|
eb078d311a | ||
|
|
462eb1cc7a | ||
|
|
8b703efb55 | ||
|
|
a08c3873b4 | ||
|
|
2ffd735e25 | ||
|
|
761772f09a | ||
|
|
de12b35216 | ||
|
|
6f8a21e547 | ||
|
|
50e3d70f70 | ||
|
|
f9a064e9aa | ||
|
|
a8507d8120 | ||
|
|
acf5b95646 | ||
|
|
cd197dc7d7 | ||
|
|
016543db40 | ||
|
|
6ed6142129 | ||
|
|
cdfee1232e | ||
|
|
25191a2443 | ||
|
|
339dd2b006 | ||
|
|
eb7a6fb9dc | ||
|
|
8b86ad2918 | ||
|
|
3d624adc09 | ||
|
|
4062a76e21 | ||
|
|
9ae5710854 | ||
|
|
494b7552ce | ||
|
|
aaecd2ae6d | ||
|
|
1e4a25c15d | ||
|
|
ea9a51ec02 | ||
|
|
4593637e23 | ||
|
|
bdae3a76d0 | ||
|
|
a370efda87 | ||
|
|
bab107ebf6 | ||
|
|
ea6dd0dc99 | ||
|
|
20b9a36604 | ||
|
|
b3b50aa8ab | ||
|
|
f749e967f1 | ||
|
|
75b5193dc4 | ||
|
|
6bc8124413 | ||
|
|
06d68e25ac | ||
|
|
19bc9a0c93 | ||
|
|
4a3f20b236 | ||
|
|
82400407b9 | ||
|
|
d49384b98b | ||
|
|
3c1072db4a | ||
|
|
41fde6f1ad | ||
|
|
620731b464 | ||
|
|
558cecea76 | ||
|
|
ff81bf1fac | ||
|
|
71717a5dbb | ||
|
|
9155a3cbf2 | ||
|
|
f98d629a78 | ||
|
|
55e04cd2cd | ||
|
|
f6d8183001 | ||
|
|
b9f4ddd480 | ||
|
|
0d9360490d | ||
|
|
8854bbbe95 | ||
|
|
b617cdc690 | ||
|
|
62d26fbafd | ||
|
|
6c38474c40 | ||
|
|
fed41ba3aa | ||
|
|
181d74a139 | ||
|
|
72d83ca171 | ||
|
|
020b1f1d71 | ||
|
|
11e57a43f7 | ||
|
|
f9647c0691 | ||
|
|
92bdf7d57b | ||
|
|
d5ef4f9313 | ||
|
|
925005a9de | ||
|
|
354ee3b6c7 | ||
|
|
9f080b4533 | ||
|
|
16b7181ebc | ||
|
|
7c1d449743 | ||
|
|
9bbb1a02e5 | ||
|
|
37035bfacd | ||
|
|
434f149e04 | ||
|
|
25f30cacc2 | ||
|
|
8f862fd1a1 | ||
|
|
5904815908 | ||
|
|
36b80c25d4 | ||
|
|
994ffe3d5f | ||
|
|
08b8ecba32 | ||
|
|
675885d875 | ||
|
|
f0b8e5ab64 | ||
|
|
9a202207b4 | ||
|
|
f4027b433d | ||
|
|
ab4fee8229 | ||
|
|
1920a190bc | ||
|
|
b9db1881ca | ||
|
|
9c1c1e609d | ||
|
|
7a2d366bdd | ||
|
|
6497e461bd | ||
|
|
6a6b750b4e | ||
|
|
7b5c51a198 | ||
|
|
600ae38c0f | ||
|
|
f5b9275192 | ||
|
|
c33e944ec4 | ||
|
|
8263bbfde2 | ||
|
|
305cd2d795 | ||
|
|
93bf6d4dc4 | ||
|
|
3546fabdfa | ||
|
|
f507e4cabd | ||
|
|
9992b1fa7e | ||
|
|
e419e59f1d | ||
|
|
a3d5a56077 | ||
|
|
7bd593f0e5 | ||
|
|
63d353a078 | ||
|
|
bf7a8b0854 | ||
|
|
09f28cf829 | ||
|
|
58f0cf2916 | ||
|
|
d6a45cced0 | ||
|
|
8cc44c4a79 | ||
|
|
5b93c78ebd | ||
|
|
2085e3ae40 | ||
|
|
3886436841 | ||
|
|
40ce73db68 | ||
|
|
27b3213bac | ||
|
|
829cfb3054 | ||
|
|
3a3d21cd01 | ||
|
|
aa47d8ecf8 | ||
|
|
e8353897eb | ||
|
|
58f9e623a4 | ||
|
|
d871c9b061 | ||
|
|
4da28bcd86 | ||
|
|
f21f05585c | ||
|
|
a606e5f79e | ||
|
|
15bf4c7018 | ||
|
|
efa3acc368 | ||
|
|
64e0ba3b77 | ||
|
|
c9ded8956c | ||
|
|
6cb6b91bd4 | ||
|
|
6470454221 | ||
|
|
a3814f644c | ||
|
|
a89d6dc468 | ||
|
|
ad8f90d12e | ||
|
|
95cb91ffad | ||
|
|
04fd072ae9 | ||
|
|
6201951e3b | ||
|
|
9f1735110c | ||
|
|
440d63ade0 | ||
|
|
09e3eb3e54 | ||
|
|
22074a5fbd | ||
|
|
5a17320c44 | ||
|
|
7548082355 | ||
|
|
36181b0ef8 | ||
|
|
d478d973fd | ||
|
|
d80986e6d0 | ||
|
|
f929bf280f | ||
|
|
0013f64c61 | ||
|
|
a2d2c61f1e | ||
|
|
700e04cc14 | ||
|
|
baa275b05b | ||
|
|
e6d6cae35c | ||
|
|
3facea9a06 | ||
|
|
a1aacbffed | ||
|
|
401402021a | ||
|
|
e7602a164a | ||
|
|
980357509d | ||
|
|
ad021e5758 | ||
|
|
5e2a6778f0 | ||
|
|
296d9a86d0 | ||
|
|
85d83ed9ba | ||
|
|
d2b64fb272 | ||
|
|
8970730ec9 | ||
|
|
bc9ffc1a79 | ||
|
|
46f562e91d | ||
|
|
3695a29b32 | ||
|
|
03eb8834c1 | ||
|
|
79f5fc6908 | ||
|
|
526ddf12d5 | ||
|
|
d3acc71d95 | ||
|
|
3438770f30 | ||
|
|
46d5d464b6 | ||
|
|
01438d630d | ||
|
|
c3d8273caa | ||
|
|
2999f2dcdd | ||
|
|
1676d02d80 | ||
|
|
65e7d0a2cd | ||
|
|
afc9141a7c | ||
|
|
fd8ba951dc | ||
|
|
6374ef8d1b | ||
|
|
9f16e7c272 | ||
|
|
b59cc28dc5 | ||
|
|
9930db8dc7 | ||
|
|
9f902bfbe9 | ||
|
|
5729a32959 | ||
|
|
86616b6936 | ||
|
|
d7a2a12129 | ||
|
|
274573df28 | ||
|
|
20234269e9 | ||
|
|
edc9a14ef5 | ||
|
|
7e6c72a198 | ||
|
|
48ae45550d | ||
|
|
aaaab9deca | ||
|
|
53d10dc597 | ||
|
|
86ef6d2dd6 | ||
|
|
beccba6d95 | ||
|
|
c01441460b | ||
|
|
68ed132e61 | ||
|
|
b9c9424103 | ||
|
|
82eda9a092 | ||
|
|
8e6237e885 | ||
|
|
e99650615d | ||
|
|
58b4dc760e | ||
|
|
131f4a6968 | ||
|
|
533880e9f1 | ||
|
|
9be23b4ff7 | ||
|
|
53af9c6c1e | ||
|
|
51af8c223d | ||
|
|
dbc951a9d0 | ||
|
|
ac3a50a31c | ||
|
|
c111257f63 | ||
|
|
67f0b82ae4 | ||
|
|
0b97aaa302 | ||
|
|
227e7d47ab | ||
|
|
9d73e1d5c1 | ||
|
|
632d73698f | ||
|
|
674e784318 | ||
|
|
d77d8dbdd1 | ||
|
|
58812a568f | ||
|
|
e768e83507 | ||
|
|
dc69e93064 | ||
|
|
832d0d5bfa | ||
|
|
04184b1582 | ||
|
|
70dabf70dd | ||
|
|
f420ac144c | ||
|
|
1bc9242644 | ||
|
|
eb36eed4c0 | ||
|
|
91aacdd955 | ||
|
|
a48e8f357a | ||
|
|
34ef43786c | ||
|
|
fbdf820734 | ||
|
|
aecb95bc92 | ||
|
|
f900cbff0b | ||
|
|
206b695e62 | ||
|
|
c94a0c94f3 | ||
|
|
5599277bf2 | ||
|
|
7a62b348cd | ||
|
|
a907cde399 | ||
|
|
77bbb64feb | ||
|
|
b5aa0b135f | ||
|
|
9976a84d42 | ||
|
|
018406d25c | ||
|
|
639cc302d2 | ||
|
|
3cbdf798a2 | ||
|
|
74ebcc5616 | ||
|
|
0685f401f3 | ||
|
|
235c179d60 | ||
|
|
caa725dc20 | ||
|
|
feff4ad890 | ||
|
|
bee067ad76 | ||
|
|
2e47b23827 | ||
|
|
88bf93a2cc | ||
|
|
3f284889ac | ||
|
|
698acad3bd | ||
|
|
20f462e603 | ||
|
|
11cb1e1f31 | ||
|
|
5b1228e14d | ||
|
|
de1a5baaca | ||
|
|
3ca8814e46 | ||
|
|
7afde45ac6 | ||
|
|
357e889dad | ||
|
|
024f316b3a | ||
|
|
2e1c2cbc6e | ||
|
|
88832596da | ||
|
|
1375854237 | ||
|
|
c7fdd81691 | ||
|
|
276d935cee | ||
|
|
9905b2608b | ||
|
|
06f80f0646 | ||
|
|
cde907e15a | ||
|
|
94c95b44ec | ||
|
|
b8e3ec8b7b | ||
|
|
9a1dc89a99 | ||
|
|
90cee00319 | ||
|
|
1ad4eba17e | ||
|
|
b87c38e232 | ||
|
|
b602c08603 | ||
|
|
b18514d9fe | ||
|
|
e2dffad962 | ||
|
|
3957fa3be6 | ||
|
|
535358b057 | ||
|
|
9f4dbf0002 | ||
|
|
10a5677241 | ||
|
|
f2cedfd08e | ||
|
|
13236d8ebc | ||
|
|
d19f0534e4 | ||
|
|
f5d79a5469 | ||
|
|
88c58237c1 | ||
|
|
03d8c187ed | ||
|
|
d3ed644b9c | ||
|
|
6bfda6743e | ||
|
|
8cf5acd183 | ||
|
|
b0432487cc | ||
|
|
e5fe1b5a92 | ||
|
|
1f403291cc | ||
|
|
edaad85990 | ||
|
|
f4aeecae84 | ||
|
|
9142f28d55 | ||
|
|
23deea0c37 | ||
|
|
cc2d6194a9 | ||
|
|
340528f5af | ||
|
|
66067a3506 | ||
|
|
eed3c518cd | ||
|
|
88b0e8cd7e | ||
|
|
028cb99586 | ||
|
|
37eacb5d61 | ||
|
|
e7956901de | ||
|
|
0e3d7cc8ca | ||
|
|
103c8a4aef | ||
|
|
b7190b6a74 | ||
|
|
ddf976e240 | ||
|
|
d23cc0a239 | ||
|
|
ff5a0d6a45 | ||
|
|
6a1e7d9a20 | ||
|
|
7eb965977a | ||
|
|
48627c0901 | ||
|
|
fbaf96eb38 | ||
|
|
31517db9bf | ||
|
|
d0ecf74836 | ||
|
|
89fb94420a | ||
|
|
3e81762f27 | ||
|
|
06a362225f | ||
|
|
62c5d8e3b9 | ||
|
|
4724fab97e | ||
|
|
b7e94f2b52 | ||
|
|
ad99bbb7e8 | ||
|
|
7a1ddf9c83 | ||
|
|
cc134da1ed | ||
|
|
e6be9ea84e | ||
|
|
718df194fe | ||
|
|
26eb52adf1 | ||
|
|
f5ec49b375 | ||
|
|
9aaa80dcc1 | ||
|
|
3463b8d374 | ||
|
|
16b3787258 | ||
|
|
269f907d1d | ||
|
|
5f2144db0f | ||
|
|
693c159360 | ||
|
|
7a6c42df62 | ||
|
|
9f984054b6 | ||
|
|
1400e57cf7 | ||
|
|
7f4b18104f | ||
|
|
d9452509b5 | ||
|
|
d120da8000 | ||
|
|
bc5ffe1828 | ||
|
|
5211267cd2 | ||
|
|
67e0956042 | ||
|
|
0467933ae9 | ||
|
|
48af2866d2 | ||
|
|
d3922d812a | ||
|
|
2893c4b4ad | ||
|
|
b8dcac03cc | ||
|
|
5f8dc32ed6 | ||
|
|
293ada96c8 | ||
|
|
6c4c4f1e9d | ||
|
|
cbfaf7fd91 | ||
|
|
abc6f68062 | ||
|
|
1331123fb4 | ||
|
|
5f92bc3d8d | ||
|
|
c8c6b63cd2 | ||
|
|
8552b676cb | ||
|
|
fe90278b8e | ||
|
|
37e6722ffb | ||
|
|
7b27fca2ad | ||
|
|
f9919bd72c | ||
|
|
3a72587a9e | ||
|
|
71d88cdcba | ||
|
|
d439b804fe | ||
|
|
84c2ee1e1c | ||
|
|
fecae2228d | ||
|
|
2580b7693c | ||
|
|
a62e713219 | ||
|
|
410780d051 | ||
|
|
bb910e20ac | ||
|
|
31a735ca25 | ||
|
|
3d069dbb1c | ||
|
|
5b3f594b2b | ||
|
|
3643719161 | ||
|
|
d743317069 | ||
|
|
f274181270 | ||
|
|
c90af47f02 | ||
|
|
7496c79ae5 | ||
|
|
11d3d93693 | ||
|
|
277d40761b | ||
|
|
27ec72cdb9 | ||
|
|
e17e8e15c7 | ||
|
|
4b6ec6f310 | ||
|
|
04c55cd602 | ||
|
|
c242ef49a6 | ||
|
|
4502ca7bf4 | ||
|
|
9c72f05fbd | ||
|
|
1fb82a6d7f | ||
|
|
9242f78b88 | ||
|
|
5b9d403b7d | ||
|
|
cc802ebc69 | ||
|
|
0129c97c83 | ||
|
|
fc01b705a5 | ||
|
|
126d080c63 | ||
|
|
d5614eb5ee | ||
|
|
c07b26d568 | ||
|
|
11fcb088e5 | ||
|
|
f889aa1b71 | ||
|
|
ee123efd7d | ||
|
|
94f53aabe1 | ||
|
|
9fe502057e | ||
|
|
17c556607a | ||
|
|
a18938d0b1 | ||
|
|
d08fb78357 | ||
|
|
906d2b6614 | ||
|
|
a09e7ca1cb | ||
|
|
3ad690d624 | ||
|
|
db06096169 | ||
|
|
99d67d531b | ||
|
|
4e8585bf9a | ||
|
|
376e5ba119 | ||
|
|
3395f35b59 | ||
|
|
102b33c3dc | ||
|
|
aa4222588a | ||
|
|
15deb66dff | ||
|
|
4a5da29cfe | ||
|
|
18963546ef | ||
|
|
3404626dd6 | ||
|
|
e970fa1d4d | ||
|
|
e5b3b7a3c0 | ||
|
|
64eb6581e3 | ||
|
|
dc9f6f3917 | ||
|
|
3c2cd5d936 | ||
|
|
6e98744aab | ||
|
|
4beb0d2902 | ||
|
|
9c62ec1d2c |
No files matched your search
@@ -10,5 +10,5 @@ updates:
|
||||
schedule:
|
||||
interval: "weekly"
|
||||
ignore:
|
||||
- dependency-name: "github.com/anyproto/go-chash"
|
||||
- dependency-name: "github.com/anytypeio/go-chash"
|
||||
|
||||
@@ -7,7 +7,7 @@ jobs:
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
GOPRIVATE: github.com/anyproto
|
||||
GOPRIVATE: github.com/anytypeio
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/setup-go@v3
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2023 Any Association
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
||||
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
|
||||
OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
@@ -1,5 +1,5 @@
|
||||
.PHONY: proto test deps
|
||||
export GOPRIVATE=github.com/anyproto
|
||||
export GOPRIVATE=github.com/anytypeio
|
||||
export PATH:=deps:$(PATH)
|
||||
|
||||
proto:
|
||||
@@ -8,8 +8,8 @@ proto:
|
||||
@$(eval P_ACL_RECORDS_PATH_PB := commonspace/object/acl/aclrecordproto)
|
||||
@$(eval P_TREE_CHANGES_PATH_PB := commonspace/object/tree/treechangeproto)
|
||||
@$(eval P_CRYPTO_PATH_PB := util/crypto/cryptoproto)
|
||||
@$(eval P_ACL_RECORDS := M$(P_ACL_RECORDS_PATH_PB)/protos/aclrecord.proto=github.com/anyproto/any-sync/$(P_ACL_RECORDS_PATH_PB))
|
||||
@$(eval P_TREE_CHANGES := M$(P_TREE_CHANGES_PATH_PB)/protos/treechange.proto=github.com/anyproto/any-sync/$(P_TREE_CHANGES_PATH_PB))
|
||||
@$(eval P_ACL_RECORDS := M$(P_ACL_RECORDS_PATH_PB)/protos/aclrecord.proto=github.com/anytypeio/any-sync/$(P_ACL_RECORDS_PATH_PB))
|
||||
@$(eval P_TREE_CHANGES := M$(P_TREE_CHANGES_PATH_PB)/protos/treechange.proto=github.com/anytypeio/any-sync/$(P_TREE_CHANGES_PATH_PB))
|
||||
|
||||
protoc --gogofaster_out=:. $(P_ACL_RECORDS_PATH_PB)/protos/*.proto
|
||||
protoc --gogofaster_out=:. $(P_TREE_CHANGES_PATH_PB)/protos/*.proto
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
//go:generate mockgen -destination mock_accountservice/mock_accountservice.go github.com/anyproto/any-sync/accountservice Service
|
||||
//go:generate mockgen -destination mock_accountservice/mock_accountservice.go github.com/anytypeio/any-sync/accountservice Service
|
||||
package accountservice
|
||||
|
||||
import (
|
||||
"github.com/anyproto/any-sync/app"
|
||||
"github.com/anyproto/any-sync/commonspace/object/accountdata"
|
||||
"github.com/anytypeio/any-sync/app"
|
||||
"github.com/anytypeio/any-sync/commonspace/object/accountdata"
|
||||
)
|
||||
|
||||
const CName = "common.accountservice"
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package mock_accountservice
|
||||
|
||||
import (
|
||||
"github.com/anyproto/any-sync/accountservice"
|
||||
"github.com/anyproto/any-sync/commonspace/object/accountdata"
|
||||
"github.com/anytypeio/any-sync/accountservice"
|
||||
"github.com/anytypeio/any-sync/commonspace/object/accountdata"
|
||||
"github.com/golang/mock/gomock"
|
||||
)
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// Code generated by MockGen. DO NOT EDIT.
|
||||
// Source: github.com/anyproto/any-sync/accountservice (interfaces: Service)
|
||||
// Source: github.com/anytypeio/any-sync/accountservice (interfaces: Service)
|
||||
|
||||
// Package mock_accountservice is a generated GoMock package.
|
||||
package mock_accountservice
|
||||
@@ -7,8 +7,8 @@ package mock_accountservice
|
||||
import (
|
||||
reflect "reflect"
|
||||
|
||||
app "github.com/anyproto/any-sync/app"
|
||||
accountdata "github.com/anyproto/any-sync/commonspace/object/accountdata"
|
||||
app "github.com/anytypeio/any-sync/app"
|
||||
accountdata "github.com/anytypeio/any-sync/commonspace/object/accountdata"
|
||||
gomock "github.com/golang/mock/gomock"
|
||||
)
|
||||
|
||||
|
||||
+9
-32
@@ -4,11 +4,10 @@ import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"github.com/anyproto/any-sync/app/logger"
|
||||
"github.com/anytypeio/any-sync/app/logger"
|
||||
"go.uber.org/zap"
|
||||
"os"
|
||||
"runtime"
|
||||
"runtime/debug"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
@@ -16,8 +15,8 @@ import (
|
||||
|
||||
var (
|
||||
// values of this vars will be defined while compilation
|
||||
AppName, GitCommit, GitBranch, GitState, GitSummary, BuildDate string
|
||||
name string
|
||||
GitCommit, GitBranch, GitState, GitSummary, BuildDate string
|
||||
name string
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -55,12 +54,11 @@ type ComponentStatable interface {
|
||||
// App is the central part of the application
|
||||
// It contains and manages all components
|
||||
type App struct {
|
||||
components []Component
|
||||
mu sync.RWMutex
|
||||
startStat Stat
|
||||
stopStat Stat
|
||||
deviceState int
|
||||
anySyncVersion string
|
||||
components []Component
|
||||
mu sync.RWMutex
|
||||
startStat Stat
|
||||
stopStat Stat
|
||||
deviceState int
|
||||
}
|
||||
|
||||
// Name returns app name
|
||||
@@ -68,10 +66,6 @@ func (app *App) Name() string {
|
||||
return name
|
||||
}
|
||||
|
||||
func (app *App) AppName() string {
|
||||
return AppName
|
||||
}
|
||||
|
||||
// Version return app version
|
||||
func (app *App) Version() string {
|
||||
return GitSummary
|
||||
@@ -263,7 +257,7 @@ func (app *App) Close(ctx context.Context) error {
|
||||
case <-time.After(StopWarningAfter):
|
||||
statLogger(app.stopStat, log).
|
||||
With(zap.String("in_progress", currentComponentStopping)).
|
||||
Warn("components close in progress")
|
||||
Warn("components close in progress")
|
||||
}
|
||||
}()
|
||||
go func() {
|
||||
@@ -317,20 +311,3 @@ func (app *App) SetDeviceState(state int) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var onceVersion sync.Once
|
||||
|
||||
func (app *App) AnySyncVersion() string {
|
||||
onceVersion.Do(func() {
|
||||
info, ok := debug.ReadBuildInfo()
|
||||
if ok {
|
||||
for _, mod := range info.Deps {
|
||||
if mod.Path == "github.com/anyproto/any-sync" {
|
||||
app.anySyncVersion = mod.Version
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
return app.anySyncVersion
|
||||
}
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
// Package ldiff provides a container of elements with fixed id and changeable content.
|
||||
// Diff can calculate the difference with another diff container (you can make it remote) with minimum hops and traffic.
|
||||
//
|
||||
//go:generate mockgen -destination mock_ldiff/mock_ldiff.go github.com/anyproto/any-sync/app/ldiff Diff,Remote
|
||||
//go:generate mockgen -destination mock_ldiff/mock_ldiff.go github.com/anytypeio/any-sync/app/ldiff Diff,Remote
|
||||
package ldiff
|
||||
|
||||
import (
|
||||
|
||||
@@ -3,9 +3,9 @@ package ldiff
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"github.com/google/uuid"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
"gopkg.in/mgo.v2/bson"
|
||||
"math"
|
||||
"sort"
|
||||
"testing"
|
||||
@@ -44,7 +44,7 @@ func TestDiff_Diff(t *testing.T) {
|
||||
d2 := New(16, 16)
|
||||
for i := 0; i < 1000; i++ {
|
||||
id := fmt.Sprint(i)
|
||||
head := uuid.NewString()
|
||||
head := bson.NewObjectId().Hex()
|
||||
d1.Set(Element{
|
||||
Id: id,
|
||||
Head: head,
|
||||
@@ -92,7 +92,7 @@ func TestDiff_Diff(t *testing.T) {
|
||||
for i := 0; i < 10; i++ {
|
||||
d2.Set(Element{
|
||||
Id: fmt.Sprint(i),
|
||||
Head: uuid.NewString(),
|
||||
Head: bson.NewObjectId().Hex(),
|
||||
})
|
||||
}
|
||||
|
||||
@@ -108,7 +108,7 @@ func TestDiff_Diff(t *testing.T) {
|
||||
for i := 0; i < 10; i++ {
|
||||
d2.Set(Element{
|
||||
Id: fmt.Sprint(i),
|
||||
Head: uuid.NewString(),
|
||||
Head: bson.NewObjectId().Hex(),
|
||||
})
|
||||
}
|
||||
var cancel func()
|
||||
@@ -123,7 +123,7 @@ func BenchmarkDiff_Ranges(b *testing.B) {
|
||||
d := New(16, 16)
|
||||
for i := 0; i < 10000; i++ {
|
||||
id := fmt.Sprint(i)
|
||||
head := uuid.NewString()
|
||||
head := bson.NewObjectId().Hex()
|
||||
d.Set(Element{
|
||||
Id: id,
|
||||
Head: head,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// Code generated by MockGen. DO NOT EDIT.
|
||||
// Source: github.com/anyproto/any-sync/app/ldiff (interfaces: Diff,Remote)
|
||||
// Source: github.com/anytypeio/any-sync/app/ldiff (interfaces: Diff,Remote)
|
||||
|
||||
// Package mock_ldiff is a generated GoMock package.
|
||||
package mock_ldiff
|
||||
@@ -8,7 +8,7 @@ import (
|
||||
context "context"
|
||||
reflect "reflect"
|
||||
|
||||
ldiff "github.com/anyproto/any-sync/app/ldiff"
|
||||
ldiff "github.com/anytypeio/any-sync/app/ldiff"
|
||||
gomock "github.com/golang/mock/gomock"
|
||||
)
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ import (
|
||||
"go.uber.org/zap"
|
||||
"go.uber.org/zap/zapcore"
|
||||
|
||||
"github.com/anyproto/any-sync/util/slice"
|
||||
"github.com/anytypeio/any-sync/util/slice"
|
||||
)
|
||||
|
||||
type LogFormat int
|
||||
|
||||
@@ -3,7 +3,7 @@ package ocache
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"github.com/anyproto/any-sync/app/logger"
|
||||
"github.com/anytypeio/any-sync/app/logger"
|
||||
"go.uber.org/zap"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
@@ -2,8 +2,8 @@ package fileblockstore
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/anyproto/any-sync/app/logger"
|
||||
"github.com/anyproto/any-sync/commonfile/fileproto/fileprotoerr"
|
||||
"github.com/anytypeio/any-sync/app/logger"
|
||||
"github.com/anytypeio/any-sync/commonfile/fileproto/fileprotoerr"
|
||||
blocks "github.com/ipfs/go-block-format"
|
||||
"github.com/ipfs/go-cid"
|
||||
)
|
||||
|
||||
@@ -2,8 +2,8 @@ package fileprotoerr
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/anyproto/any-sync/commonfile/fileproto"
|
||||
"github.com/anyproto/any-sync/net/rpc/rpcerr"
|
||||
"github.com/anytypeio/any-sync/commonfile/fileproto"
|
||||
"github.com/anytypeio/any-sync/net/rpc/rpcerr"
|
||||
)
|
||||
|
||||
var (
|
||||
|
||||
@@ -2,7 +2,7 @@ package fileservice
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/anyproto/any-sync/commonfile/fileblockstore"
|
||||
"github.com/anytypeio/any-sync/commonfile/fileblockstore"
|
||||
blocks "github.com/ipfs/go-block-format"
|
||||
"github.com/ipfs/go-blockservice"
|
||||
"github.com/ipfs/go-cid"
|
||||
|
||||
@@ -3,9 +3,9 @@ package fileservice
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"github.com/anyproto/any-sync/app"
|
||||
"github.com/anyproto/any-sync/app/logger"
|
||||
"github.com/anyproto/any-sync/commonfile/fileblockstore"
|
||||
"github.com/anytypeio/any-sync/app"
|
||||
"github.com/anytypeio/any-sync/app/logger"
|
||||
"github.com/anytypeio/any-sync/commonfile/fileblockstore"
|
||||
"github.com/ipfs/go-cid"
|
||||
chunker "github.com/ipfs/go-ipfs-chunker"
|
||||
ipld "github.com/ipfs/go-ipld-format"
|
||||
|
||||
@@ -2,9 +2,9 @@ package commonspace
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/anyproto/any-sync/commonspace/object/syncobjectgetter"
|
||||
"github.com/anyproto/any-sync/commonspace/object/tree/objecttree"
|
||||
"github.com/anyproto/any-sync/commonspace/object/treemanager"
|
||||
"github.com/anytypeio/any-sync/commonspace/object/syncobjectgetter"
|
||||
"github.com/anytypeio/any-sync/commonspace/object/tree/objecttree"
|
||||
"github.com/anytypeio/any-sync/commonspace/object/treemanager"
|
||||
"sync/atomic"
|
||||
)
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package commonspace
|
||||
|
||||
import (
|
||||
"github.com/anyproto/any-sync/commonspace/object/tree/treestorage"
|
||||
"github.com/anyproto/any-sync/commonspace/spacestorage"
|
||||
"github.com/anytypeio/any-sync/commonspace/object/tree/treestorage"
|
||||
"github.com/anytypeio/any-sync/commonspace/spacestorage"
|
||||
)
|
||||
|
||||
type commonStorage struct {
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
//go:generate mockgen -destination mock_credentialprovider/mock_credentialprovider.go github.com/anyproto/any-sync/commonspace/credentialprovider CredentialProvider
|
||||
//go:generate mockgen -destination mock_credentialprovider/mock_credentialprovider.go github.com/anytypeio/any-sync/commonspace/credentialprovider CredentialProvider
|
||||
package credentialprovider
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/anyproto/any-sync/commonspace/spacesyncproto"
|
||||
"github.com/anytypeio/any-sync/commonspace/spacesyncproto"
|
||||
)
|
||||
|
||||
const CName = "common.commonspace.credentialprovider"
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// Code generated by MockGen. DO NOT EDIT.
|
||||
// Source: github.com/anyproto/any-sync/commonspace/credentialprovider (interfaces: CredentialProvider)
|
||||
// Source: github.com/anytypeio/any-sync/commonspace/credentialprovider (interfaces: CredentialProvider)
|
||||
|
||||
// Package mock_credentialprovider is a generated GoMock package.
|
||||
package mock_credentialprovider
|
||||
@@ -8,7 +8,7 @@ import (
|
||||
context "context"
|
||||
reflect "reflect"
|
||||
|
||||
spacesyncproto "github.com/anyproto/any-sync/commonspace/spacesyncproto"
|
||||
spacesyncproto "github.com/anytypeio/any-sync/commonspace/spacesyncproto"
|
||||
gomock "github.com/golang/mock/gomock"
|
||||
)
|
||||
|
||||
|
||||
@@ -1,271 +0,0 @@
|
||||
package commonspace
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"github.com/anyproto/any-sync/commonspace/object/accountdata"
|
||||
"github.com/anyproto/any-sync/commonspace/object/tree/objecttree"
|
||||
"github.com/anyproto/any-sync/commonspace/object/tree/treechangeproto"
|
||||
"github.com/anyproto/any-sync/commonspace/object/tree/treestorage"
|
||||
"github.com/anyproto/any-sync/commonspace/settings"
|
||||
"github.com/anyproto/any-sync/commonspace/settings/settingsstate"
|
||||
"github.com/anyproto/any-sync/commonspace/spacestorage"
|
||||
"github.com/anyproto/any-sync/commonspace/spacesyncproto"
|
||||
"github.com/anyproto/any-sync/util/crypto"
|
||||
"github.com/stretchr/testify/require"
|
||||
"math/rand"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
func addIncorrectSnapshot(settingsObject settings.SettingsObject, acc *accountdata.AccountKeys, partialIds map[string]struct{}, newId string) (err error) {
|
||||
factory := settingsstate.NewChangeFactory()
|
||||
bytes, err := factory.CreateObjectDeleteChange(newId, &settingsstate.State{DeletedIds: partialIds}, true)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
ch, err := settingsObject.PrepareChange(objecttree.SignableChangeContent{
|
||||
Data: bytes,
|
||||
Key: acc.SignKey,
|
||||
IsSnapshot: true,
|
||||
IsEncrypted: false,
|
||||
Timestamp: time.Now().Unix(),
|
||||
})
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
res, err := settingsObject.AddRawChanges(context.Background(), objecttree.RawChangesPayload{
|
||||
NewHeads: []string{ch.Id},
|
||||
RawChanges: []*treechangeproto.RawTreeChangeWithId{ch},
|
||||
})
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
if res.Mode != objecttree.Rebuild {
|
||||
return fmt.Errorf("incorrect mode: %d", res.Mode)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func TestSpaceDeleteIds(t *testing.T) {
|
||||
fx := newFixture(t)
|
||||
acc := fx.account.Account()
|
||||
rk := crypto.NewAES()
|
||||
ctx := context.Background()
|
||||
totalObjs := 1500
|
||||
|
||||
// creating space
|
||||
sp, err := fx.spaceService.CreateSpace(ctx, SpaceCreatePayload{
|
||||
SigningKey: acc.SignKey,
|
||||
SpaceType: "type",
|
||||
ReadKey: rk.Bytes(),
|
||||
ReplicationKey: 10,
|
||||
MasterKey: acc.PeerKey,
|
||||
})
|
||||
require.NoError(t, err)
|
||||
require.NotNil(t, sp)
|
||||
|
||||
// initializing space
|
||||
spc, err := fx.spaceService.NewSpace(ctx, sp)
|
||||
require.NoError(t, err)
|
||||
require.NotNil(t, spc)
|
||||
// adding space to tree manager
|
||||
fx.treeManager.space = spc
|
||||
err = spc.Init(ctx)
|
||||
require.NoError(t, err)
|
||||
|
||||
var ids []string
|
||||
for i := 0; i < totalObjs; i++ {
|
||||
// creating a tree
|
||||
bytes := make([]byte, 32)
|
||||
rand.Read(bytes)
|
||||
doc, err := spc.CreateTree(ctx, objecttree.ObjectTreeCreatePayload{
|
||||
PrivKey: acc.SignKey,
|
||||
ChangeType: "some",
|
||||
SpaceId: spc.Id(),
|
||||
IsEncrypted: false,
|
||||
Seed: bytes,
|
||||
Timestamp: time.Now().Unix(),
|
||||
})
|
||||
require.NoError(t, err)
|
||||
tr, err := spc.PutTree(ctx, doc, nil)
|
||||
require.NoError(t, err)
|
||||
ids = append(ids, tr.Id())
|
||||
tr.Close()
|
||||
}
|
||||
// deleting trees
|
||||
for _, id := range ids {
|
||||
err = spc.DeleteTree(ctx, id)
|
||||
require.NoError(t, err)
|
||||
}
|
||||
time.Sleep(3 * time.Second)
|
||||
spc.Close()
|
||||
require.Equal(t, len(ids), len(fx.treeManager.deletedIds))
|
||||
}
|
||||
|
||||
func createTree(t *testing.T, ctx context.Context, spc Space, acc *accountdata.AccountKeys) string {
|
||||
bytes := make([]byte, 32)
|
||||
rand.Read(bytes)
|
||||
doc, err := spc.CreateTree(ctx, objecttree.ObjectTreeCreatePayload{
|
||||
PrivKey: acc.SignKey,
|
||||
ChangeType: "some",
|
||||
SpaceId: spc.Id(),
|
||||
IsEncrypted: false,
|
||||
Seed: bytes,
|
||||
Timestamp: time.Now().Unix(),
|
||||
})
|
||||
require.NoError(t, err)
|
||||
tr, err := spc.PutTree(ctx, doc, nil)
|
||||
require.NoError(t, err)
|
||||
tr.Close()
|
||||
return tr.Id()
|
||||
}
|
||||
|
||||
func TestSpaceDeleteIdsIncorrectSnapshot(t *testing.T) {
|
||||
fx := newFixture(t)
|
||||
acc := fx.account.Account()
|
||||
rk := crypto.NewAES()
|
||||
ctx := context.Background()
|
||||
totalObjs := 1500
|
||||
partialObjs := 300
|
||||
|
||||
// creating space
|
||||
sp, err := fx.spaceService.CreateSpace(ctx, SpaceCreatePayload{
|
||||
SigningKey: acc.SignKey,
|
||||
SpaceType: "type",
|
||||
ReadKey: rk.Bytes(),
|
||||
ReplicationKey: 10,
|
||||
MasterKey: acc.PeerKey,
|
||||
})
|
||||
require.NoError(t, err)
|
||||
require.NotNil(t, sp)
|
||||
|
||||
// initializing space
|
||||
spc, err := fx.spaceService.NewSpace(ctx, sp)
|
||||
require.NoError(t, err)
|
||||
require.NotNil(t, spc)
|
||||
// adding space to tree manager
|
||||
fx.treeManager.space = spc
|
||||
err = spc.Init(ctx)
|
||||
require.NoError(t, err)
|
||||
|
||||
settingsObject := spc.(*space).settingsObject
|
||||
var ids []string
|
||||
for i := 0; i < totalObjs; i++ {
|
||||
id := createTree(t, ctx, spc, acc)
|
||||
ids = append(ids, id)
|
||||
}
|
||||
// copying storage, so we will have all the trees locally
|
||||
inmemory := spc.Storage().(*commonStorage).SpaceStorage.(*spacestorage.InMemorySpaceStorage)
|
||||
storageCopy := inmemory.CopyStorage()
|
||||
treesCopy := inmemory.AllTrees()
|
||||
|
||||
// deleting trees
|
||||
for _, id := range ids {
|
||||
err = spc.DeleteTree(ctx, id)
|
||||
require.NoError(t, err)
|
||||
}
|
||||
mapIds := map[string]struct{}{}
|
||||
for _, id := range ids[:partialObjs] {
|
||||
mapIds[id] = struct{}{}
|
||||
}
|
||||
// adding snapshot that breaks the state
|
||||
err = addIncorrectSnapshot(settingsObject, acc, mapIds, ids[partialObjs])
|
||||
require.NoError(t, err)
|
||||
// copying the contents of the settings tree
|
||||
treesCopy[settingsObject.Id()] = settingsObject.Storage()
|
||||
storageCopy.SetTrees(treesCopy)
|
||||
spc.Close()
|
||||
time.Sleep(100 * time.Millisecond)
|
||||
// now we replace the storage, so the trees are back, but the settings object says that they are deleted
|
||||
fx.storageProvider.(*spacestorage.InMemorySpaceStorageProvider).SetStorage(storageCopy)
|
||||
|
||||
spc, err = fx.spaceService.NewSpace(ctx, sp)
|
||||
require.NoError(t, err)
|
||||
require.NotNil(t, spc)
|
||||
fx.treeManager.space = spc
|
||||
fx.treeManager.deletedIds = nil
|
||||
err = spc.Init(ctx)
|
||||
require.NoError(t, err)
|
||||
|
||||
// waiting until everything is deleted
|
||||
time.Sleep(3 * time.Second)
|
||||
require.Equal(t, len(ids), len(fx.treeManager.deletedIds))
|
||||
|
||||
// checking that new snapshot will contain all the changes
|
||||
settingsObject = spc.(*space).settingsObject
|
||||
settings.DoSnapshot = func(treeLen int) bool {
|
||||
return true
|
||||
}
|
||||
id := createTree(t, ctx, spc, acc)
|
||||
err = spc.DeleteTree(ctx, id)
|
||||
require.NoError(t, err)
|
||||
delIds := settingsObject.Root().Model.(*spacesyncproto.SettingsData).Snapshot.DeletedIds
|
||||
require.Equal(t, totalObjs+1, len(delIds))
|
||||
}
|
||||
|
||||
func TestSpaceDeleteIdsMarkDeleted(t *testing.T) {
|
||||
fx := newFixture(t)
|
||||
acc := fx.account.Account()
|
||||
rk := crypto.NewAES()
|
||||
ctx := context.Background()
|
||||
totalObjs := 1500
|
||||
|
||||
// creating space
|
||||
sp, err := fx.spaceService.CreateSpace(ctx, SpaceCreatePayload{
|
||||
SigningKey: acc.SignKey,
|
||||
SpaceType: "type",
|
||||
ReadKey: rk.Bytes(),
|
||||
ReplicationKey: 10,
|
||||
MasterKey: acc.PeerKey,
|
||||
})
|
||||
require.NoError(t, err)
|
||||
require.NotNil(t, sp)
|
||||
|
||||
// initializing space
|
||||
spc, err := fx.spaceService.NewSpace(ctx, sp)
|
||||
require.NoError(t, err)
|
||||
require.NotNil(t, spc)
|
||||
// adding space to tree manager
|
||||
fx.treeManager.space = spc
|
||||
err = spc.Init(ctx)
|
||||
require.NoError(t, err)
|
||||
|
||||
settingsObject := spc.(*space).settingsObject
|
||||
var ids []string
|
||||
for i := 0; i < totalObjs; i++ {
|
||||
id := createTree(t, ctx, spc, acc)
|
||||
ids = append(ids, id)
|
||||
}
|
||||
// copying storage, so we will have the same contents, except for empty trees
|
||||
inmemory := spc.Storage().(*commonStorage).SpaceStorage.(*spacestorage.InMemorySpaceStorage)
|
||||
storageCopy := inmemory.CopyStorage()
|
||||
|
||||
// deleting trees, this will prepare the document to have all the deletion changes
|
||||
for _, id := range ids {
|
||||
err = spc.DeleteTree(ctx, id)
|
||||
require.NoError(t, err)
|
||||
}
|
||||
treesMap := map[string]treestorage.TreeStorage{}
|
||||
// copying the contents of the settings tree
|
||||
treesMap[settingsObject.Id()] = settingsObject.Storage()
|
||||
storageCopy.SetTrees(treesMap)
|
||||
spc.Close()
|
||||
time.Sleep(100 * time.Millisecond)
|
||||
// now we replace the storage, so the trees are back, but the settings object says that they are deleted
|
||||
fx.storageProvider.(*spacestorage.InMemorySpaceStorageProvider).SetStorage(storageCopy)
|
||||
|
||||
spc, err = fx.spaceService.NewSpace(ctx, sp)
|
||||
require.NoError(t, err)
|
||||
require.NotNil(t, spc)
|
||||
fx.treeManager.space = spc
|
||||
fx.treeManager.deletedIds = nil
|
||||
fx.treeManager.markedIds = nil
|
||||
err = spc.Init(ctx)
|
||||
require.NoError(t, err)
|
||||
|
||||
// waiting until everything is deleted
|
||||
time.Sleep(3 * time.Second)
|
||||
require.Equal(t, len(ids), len(fx.treeManager.markedIds))
|
||||
require.Zero(t, len(fx.treeManager.deletedIds))
|
||||
}
|
||||
@@ -3,17 +3,18 @@ package headsync
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"github.com/anyproto/any-sync/app/ldiff"
|
||||
"github.com/anyproto/any-sync/app/logger"
|
||||
"github.com/anyproto/any-sync/commonspace/credentialprovider"
|
||||
"github.com/anyproto/any-sync/commonspace/object/treemanager"
|
||||
"github.com/anyproto/any-sync/commonspace/peermanager"
|
||||
"github.com/anyproto/any-sync/commonspace/settings/settingsstate"
|
||||
"github.com/anyproto/any-sync/commonspace/spacestorage"
|
||||
"github.com/anyproto/any-sync/commonspace/spacesyncproto"
|
||||
"github.com/anyproto/any-sync/commonspace/syncstatus"
|
||||
"github.com/anyproto/any-sync/net/peer"
|
||||
"github.com/anyproto/any-sync/net/rpc/rpcerr"
|
||||
"github.com/anytypeio/any-sync/app/ldiff"
|
||||
"github.com/anytypeio/any-sync/app/logger"
|
||||
"github.com/anytypeio/any-sync/commonspace/credentialprovider"
|
||||
"github.com/anytypeio/any-sync/commonspace/object/tree/synctree"
|
||||
"github.com/anytypeio/any-sync/commonspace/object/treemanager"
|
||||
"github.com/anytypeio/any-sync/commonspace/peermanager"
|
||||
"github.com/anytypeio/any-sync/commonspace/settings/settingsstate"
|
||||
"github.com/anytypeio/any-sync/commonspace/spacestorage"
|
||||
"github.com/anytypeio/any-sync/commonspace/spacesyncproto"
|
||||
"github.com/anytypeio/any-sync/commonspace/syncstatus"
|
||||
"github.com/anytypeio/any-sync/net/peer"
|
||||
"github.com/anytypeio/any-sync/net/rpc/rpcerr"
|
||||
"go.uber.org/zap"
|
||||
"time"
|
||||
)
|
||||
@@ -23,7 +24,6 @@ type DiffSyncer interface {
|
||||
RemoveObjects(ids []string)
|
||||
UpdateHeads(id string, heads []string)
|
||||
Init(deletionState settingsstate.ObjectDeletionState)
|
||||
Close() error
|
||||
}
|
||||
|
||||
func newDiffSyncer(
|
||||
@@ -39,7 +39,7 @@ func newDiffSyncer(
|
||||
return &diffSyncer{
|
||||
diff: diff,
|
||||
spaceId: spaceId,
|
||||
treeManager: cache,
|
||||
cache: cache,
|
||||
storage: storage,
|
||||
peerManager: peerManager,
|
||||
clientFactory: clientFactory,
|
||||
@@ -53,20 +53,18 @@ type diffSyncer struct {
|
||||
spaceId string
|
||||
diff ldiff.Diff
|
||||
peerManager peermanager.PeerManager
|
||||
treeManager treemanager.TreeManager
|
||||
cache treemanager.TreeManager
|
||||
storage spacestorage.SpaceStorage
|
||||
clientFactory spacesyncproto.ClientFactory
|
||||
log logger.CtxLogger
|
||||
deletionState settingsstate.ObjectDeletionState
|
||||
credentialProvider credentialprovider.CredentialProvider
|
||||
syncStatus syncstatus.StatusUpdater
|
||||
treeSyncer treemanager.TreeSyncer
|
||||
}
|
||||
|
||||
func (d *diffSyncer) Init(deletionState settingsstate.ObjectDeletionState) {
|
||||
d.deletionState = deletionState
|
||||
d.deletionState.AddObserver(d.RemoveObjects)
|
||||
d.treeSyncer = d.treeManager.NewTreeSyncer(d.spaceId, d.treeManager)
|
||||
}
|
||||
|
||||
func (d *diffSyncer) RemoveObjects(ids []string) {
|
||||
@@ -126,7 +124,7 @@ func (d *diffSyncer) syncWithPeer(ctx context.Context, p peer.Peer) (err error)
|
||||
if err != nil && err != spacesyncproto.ErrSpaceMissing {
|
||||
if err == spacesyncproto.ErrSpaceIsDeleted {
|
||||
d.log.Debug("got space deleted while syncing")
|
||||
d.treeSyncer.SyncAll(ctx, p.Id(), []string{d.storage.SpaceSettingsId()}, nil)
|
||||
d.syncTrees(ctx, p.Id(), []string{d.storage.SpaceSettingsId()})
|
||||
}
|
||||
d.syncStatus.SetNodesOnline(p.Id(), false)
|
||||
return fmt.Errorf("diff error: %v", err)
|
||||
@@ -139,24 +137,45 @@ func (d *diffSyncer) syncWithPeer(ctx context.Context, p peer.Peer) (err error)
|
||||
|
||||
totalLen := len(newIds) + len(changedIds) + len(removedIds)
|
||||
// not syncing ids which were removed through settings document
|
||||
missingIds := d.deletionState.Filter(newIds)
|
||||
existingIds := append(d.deletionState.Filter(removedIds), d.deletionState.Filter(changedIds)...)
|
||||
filteredIds := d.deletionState.FilterJoin(newIds, changedIds, removedIds)
|
||||
|
||||
d.syncStatus.RemoveAllExcept(p.Id(), existingIds, stateCounter)
|
||||
d.syncStatus.RemoveAllExcept(p.Id(), filteredIds, stateCounter)
|
||||
|
||||
d.syncTrees(ctx, p.Id(), filteredIds)
|
||||
|
||||
err = d.treeSyncer.SyncAll(ctx, p.Id(), existingIds, missingIds)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
d.log.Info("sync done:", zap.Int("newIds", len(newIds)),
|
||||
zap.Int("changedIds", len(changedIds)),
|
||||
zap.Int("removedIds", len(removedIds)),
|
||||
zap.Int("already deleted ids", totalLen-len(existingIds)-len(missingIds)),
|
||||
zap.Int("already deleted ids", totalLen-len(filteredIds)),
|
||||
zap.String("peerId", p.Id()),
|
||||
)
|
||||
return
|
||||
}
|
||||
|
||||
func (d *diffSyncer) syncTrees(ctx context.Context, peerId string, trees []string) {
|
||||
for _, tId := range trees {
|
||||
tree, err := d.cache.GetTree(ctx, d.spaceId, tId)
|
||||
if err != nil {
|
||||
d.log.InfoCtx(ctx, "can't load tree", zap.Error(err))
|
||||
continue
|
||||
}
|
||||
syncTree, ok := tree.(synctree.SyncTree)
|
||||
if !ok {
|
||||
d.log.InfoCtx(ctx, "not a sync tree", zap.String("objectId", tId))
|
||||
continue
|
||||
}
|
||||
// the idea why we call it directly is that if we try to get it from cache
|
||||
// it may be already there (i.e. loaded)
|
||||
// and build func will not be called, thus we won't sync the tree
|
||||
// therefore we just do it manually
|
||||
if err = syncTree.SyncWithPeer(ctx, peerId); err != nil {
|
||||
d.log.WarnCtx(ctx, "synctree.SyncWithPeer error", zap.Error(err), zap.String("treeId", tId))
|
||||
} else {
|
||||
d.log.DebugCtx(ctx, "success synctree.SyncWithPeer", zap.String("treeId", tId))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (d *diffSyncer) sendPushSpaceRequest(ctx context.Context, peerId string, cl spacesyncproto.DRPCSpaceSyncClient) (err error) {
|
||||
aclStorage, err := d.storage.AclStorage()
|
||||
if err != nil {
|
||||
@@ -219,7 +238,3 @@ func (d *diffSyncer) subscribe(ctx context.Context, peerId string) (err error) {
|
||||
Payload: payload,
|
||||
})
|
||||
}
|
||||
|
||||
func (d *diffSyncer) Close() error {
|
||||
return d.treeSyncer.Close()
|
||||
}
|
||||
@@ -4,22 +4,22 @@ import (
|
||||
"bytes"
|
||||
"context"
|
||||
"fmt"
|
||||
"github.com/anyproto/any-sync/app/ldiff"
|
||||
"github.com/anyproto/any-sync/app/ldiff/mock_ldiff"
|
||||
"github.com/anyproto/any-sync/app/logger"
|
||||
"github.com/anyproto/any-sync/commonspace/credentialprovider/mock_credentialprovider"
|
||||
"github.com/anyproto/any-sync/commonspace/object/acl/aclrecordproto"
|
||||
"github.com/anyproto/any-sync/commonspace/object/acl/liststorage/mock_liststorage"
|
||||
"github.com/anyproto/any-sync/commonspace/object/tree/treechangeproto"
|
||||
mock_treestorage "github.com/anyproto/any-sync/commonspace/object/tree/treestorage/mock_treestorage"
|
||||
"github.com/anyproto/any-sync/commonspace/object/treemanager/mock_treemanager"
|
||||
"github.com/anyproto/any-sync/commonspace/peermanager/mock_peermanager"
|
||||
"github.com/anyproto/any-sync/commonspace/settings/settingsstate/mock_settingsstate"
|
||||
"github.com/anyproto/any-sync/commonspace/spacestorage/mock_spacestorage"
|
||||
"github.com/anyproto/any-sync/commonspace/spacesyncproto"
|
||||
"github.com/anyproto/any-sync/commonspace/spacesyncproto/mock_spacesyncproto"
|
||||
"github.com/anyproto/any-sync/commonspace/syncstatus"
|
||||
"github.com/anyproto/any-sync/net/peer"
|
||||
"github.com/anytypeio/any-sync/app/ldiff"
|
||||
"github.com/anytypeio/any-sync/app/ldiff/mock_ldiff"
|
||||
"github.com/anytypeio/any-sync/app/logger"
|
||||
"github.com/anytypeio/any-sync/commonspace/credentialprovider/mock_credentialprovider"
|
||||
"github.com/anytypeio/any-sync/commonspace/object/acl/aclrecordproto"
|
||||
"github.com/anytypeio/any-sync/commonspace/object/acl/liststorage/mock_liststorage"
|
||||
"github.com/anytypeio/any-sync/commonspace/object/tree/treechangeproto"
|
||||
mock_treestorage "github.com/anytypeio/any-sync/commonspace/object/tree/treestorage/mock_treestorage"
|
||||
"github.com/anytypeio/any-sync/commonspace/object/treemanager/mock_treemanager"
|
||||
"github.com/anytypeio/any-sync/commonspace/peermanager/mock_peermanager"
|
||||
"github.com/anytypeio/any-sync/commonspace/settings/settingsstate/mock_settingsstate"
|
||||
"github.com/anytypeio/any-sync/commonspace/spacestorage/mock_spacestorage"
|
||||
"github.com/anytypeio/any-sync/commonspace/spacesyncproto"
|
||||
"github.com/anytypeio/any-sync/commonspace/spacesyncproto/mock_spacesyncproto"
|
||||
"github.com/anytypeio/any-sync/commonspace/syncstatus"
|
||||
"github.com/anytypeio/any-sync/net/peer"
|
||||
"github.com/golang/mock/gomock"
|
||||
"github.com/libp2p/go-libp2p/core/sec"
|
||||
"github.com/stretchr/testify/require"
|
||||
@@ -51,10 +51,6 @@ func (p pushSpaceRequestMatcher) String() string {
|
||||
|
||||
type mockPeer struct{}
|
||||
|
||||
func (m mockPeer) Addr() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m mockPeer) TryClose(objectTTL time.Duration) (res bool, err error) {
|
||||
return true, m.Close()
|
||||
}
|
||||
@@ -119,7 +115,6 @@ func TestDiffSyncer_Sync(t *testing.T) {
|
||||
factory := spacesyncproto.ClientFactoryFunc(func(cc drpc.Conn) spacesyncproto.DRPCSpaceSyncClient {
|
||||
return clientMock
|
||||
})
|
||||
treeSyncerMock := mock_treemanager.NewMockTreeSyncer(ctrl)
|
||||
credentialProvider := mock_credentialprovider.NewMockCredentialProvider(ctrl)
|
||||
delState := mock_settingsstate.NewMockObjectDeletionState(ctrl)
|
||||
spaceId := "spaceId"
|
||||
@@ -127,21 +122,21 @@ func TestDiffSyncer_Sync(t *testing.T) {
|
||||
l := logger.NewNamed(spaceId)
|
||||
diffSyncer := newDiffSyncer(spaceId, diffMock, peerManagerMock, cacheMock, stMock, factory, syncstatus.NewNoOpSyncStatus(), credentialProvider, l)
|
||||
delState.EXPECT().AddObserver(gomock.Any())
|
||||
cacheMock.EXPECT().NewTreeSyncer(spaceId, gomock.Any()).Return(treeSyncerMock)
|
||||
diffSyncer.Init(delState)
|
||||
|
||||
t.Run("diff syncer sync", func(t *testing.T) {
|
||||
mPeer := mockPeer{}
|
||||
peerManagerMock.EXPECT().
|
||||
GetResponsiblePeers(gomock.Any()).
|
||||
Return([]peer.Peer{mPeer}, nil)
|
||||
Return([]peer.Peer{mockPeer{}}, nil)
|
||||
diffMock.EXPECT().
|
||||
Diff(gomock.Any(), gomock.Eq(NewRemoteDiff(spaceId, clientMock))).
|
||||
Return([]string{"new"}, []string{"changed"}, nil, nil)
|
||||
delState.EXPECT().Filter([]string{"new"}).Return([]string{"new"}).Times(1)
|
||||
delState.EXPECT().Filter([]string{"changed"}).Return([]string{"changed"}).Times(1)
|
||||
delState.EXPECT().Filter(nil).Return(nil).Times(1)
|
||||
treeSyncerMock.EXPECT().SyncAll(gomock.Any(), mPeer.Id(), []string{"changed"}, []string{"new"}).Return(nil)
|
||||
delState.EXPECT().FilterJoin(gomock.Any()).Return([]string{"new", "changed"})
|
||||
for _, arg := range []string{"new", "changed"} {
|
||||
cacheMock.EXPECT().
|
||||
GetTree(gomock.Any(), spaceId, arg).
|
||||
Return(nil, nil)
|
||||
}
|
||||
require.NoError(t, diffSyncer.Sync(ctx))
|
||||
})
|
||||
|
||||
@@ -228,15 +223,16 @@ func TestDiffSyncer_Sync(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("diff syncer sync space is deleted error", func(t *testing.T) {
|
||||
mPeer := mockPeer{}
|
||||
peerManagerMock.EXPECT().
|
||||
GetResponsiblePeers(gomock.Any()).
|
||||
Return([]peer.Peer{mPeer}, nil)
|
||||
Return([]peer.Peer{mockPeer{}}, nil)
|
||||
diffMock.EXPECT().
|
||||
Diff(gomock.Any(), gomock.Eq(NewRemoteDiff(spaceId, clientMock))).
|
||||
Return(nil, nil, nil, spacesyncproto.ErrSpaceIsDeleted)
|
||||
stMock.EXPECT().SpaceSettingsId().Return("settingsId")
|
||||
treeSyncerMock.EXPECT().SyncAll(gomock.Any(), mPeer.Id(), []string{"settingsId"}, nil).Return(nil)
|
||||
cacheMock.EXPECT().
|
||||
GetTree(gomock.Any(), spaceId, "settingsId").
|
||||
Return(nil, nil)
|
||||
|
||||
require.NoError(t, diffSyncer.Sync(ctx))
|
||||
})
|
||||
|
||||
@@ -1,20 +1,20 @@
|
||||
//go:generate mockgen -destination mock_headsync/mock_headsync.go github.com/anyproto/any-sync/commonspace/headsync DiffSyncer
|
||||
//go:generate mockgen -destination mock_headsync/mock_headsync.go github.com/anytypeio/any-sync/commonspace/headsync DiffSyncer
|
||||
package headsync
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/anyproto/any-sync/app/ldiff"
|
||||
"github.com/anyproto/any-sync/app/logger"
|
||||
"github.com/anyproto/any-sync/commonspace/credentialprovider"
|
||||
"github.com/anyproto/any-sync/commonspace/object/treemanager"
|
||||
"github.com/anyproto/any-sync/commonspace/peermanager"
|
||||
"github.com/anyproto/any-sync/commonspace/settings/settingsstate"
|
||||
"github.com/anyproto/any-sync/commonspace/spacestorage"
|
||||
"github.com/anyproto/any-sync/commonspace/spacesyncproto"
|
||||
"github.com/anyproto/any-sync/commonspace/syncstatus"
|
||||
"github.com/anyproto/any-sync/net/peer"
|
||||
"github.com/anyproto/any-sync/nodeconf"
|
||||
"github.com/anyproto/any-sync/util/periodicsync"
|
||||
"github.com/anytypeio/any-sync/app/ldiff"
|
||||
"github.com/anytypeio/any-sync/app/logger"
|
||||
"github.com/anytypeio/any-sync/commonspace/credentialprovider"
|
||||
"github.com/anytypeio/any-sync/commonspace/object/treemanager"
|
||||
"github.com/anytypeio/any-sync/commonspace/peermanager"
|
||||
"github.com/anytypeio/any-sync/commonspace/settings/settingsstate"
|
||||
"github.com/anytypeio/any-sync/commonspace/spacestorage"
|
||||
"github.com/anytypeio/any-sync/commonspace/spacesyncproto"
|
||||
"github.com/anytypeio/any-sync/commonspace/syncstatus"
|
||||
"github.com/anytypeio/any-sync/net/peer"
|
||||
"github.com/anytypeio/any-sync/nodeconf"
|
||||
"github.com/anytypeio/any-sync/util/periodicsync"
|
||||
"go.uber.org/zap"
|
||||
"golang.org/x/exp/slices"
|
||||
"strings"
|
||||
@@ -136,7 +136,7 @@ func (d *headSync) RemoveObjects(ids []string) {
|
||||
|
||||
func (d *headSync) Close() (err error) {
|
||||
d.periodicSync.Close()
|
||||
return d.syncer.Close()
|
||||
return nil
|
||||
}
|
||||
|
||||
func (d *headSync) fillDiff(objectIds []string) {
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
package headsync
|
||||
|
||||
import (
|
||||
"github.com/anyproto/any-sync/app/ldiff"
|
||||
"github.com/anyproto/any-sync/app/ldiff/mock_ldiff"
|
||||
"github.com/anyproto/any-sync/app/logger"
|
||||
"github.com/anyproto/any-sync/commonspace/headsync/mock_headsync"
|
||||
"github.com/anyproto/any-sync/commonspace/object/tree/treestorage/mock_treestorage"
|
||||
"github.com/anyproto/any-sync/commonspace/settings/settingsstate/mock_settingsstate"
|
||||
"github.com/anyproto/any-sync/commonspace/spacestorage/mock_spacestorage"
|
||||
"github.com/anyproto/any-sync/util/periodicsync/mock_periodicsync"
|
||||
"github.com/anytypeio/any-sync/app/ldiff"
|
||||
"github.com/anytypeio/any-sync/app/ldiff/mock_ldiff"
|
||||
"github.com/anytypeio/any-sync/app/logger"
|
||||
"github.com/anytypeio/any-sync/commonspace/headsync/mock_headsync"
|
||||
"github.com/anytypeio/any-sync/commonspace/object/tree/treestorage/mock_treestorage"
|
||||
"github.com/anytypeio/any-sync/commonspace/settings/settingsstate/mock_settingsstate"
|
||||
"github.com/anytypeio/any-sync/commonspace/spacestorage/mock_spacestorage"
|
||||
"github.com/anytypeio/any-sync/util/periodicsync/mock_periodicsync"
|
||||
"github.com/golang/mock/gomock"
|
||||
"testing"
|
||||
)
|
||||
@@ -65,7 +65,6 @@ func TestDiffService(t *testing.T) {
|
||||
|
||||
t.Run("close", func(t *testing.T) {
|
||||
pSyncMock.EXPECT().Close()
|
||||
syncer.EXPECT().Close()
|
||||
service.Close()
|
||||
})
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
// Code generated by MockGen. DO NOT EDIT.
|
||||
// Source: github.com/anyproto/any-sync/commonspace/headsync (interfaces: DiffSyncer)
|
||||
// Source: github.com/anytypeio/any-sync/commonspace/headsync (interfaces: DiffSyncer)
|
||||
|
||||
// Package mock_headsync is a generated GoMock package.
|
||||
package mock_headsync
|
||||
@@ -8,7 +8,7 @@ import (
|
||||
context "context"
|
||||
reflect "reflect"
|
||||
|
||||
settingsstate "github.com/anyproto/any-sync/commonspace/settings/settingsstate"
|
||||
settingsstate "github.com/anytypeio/any-sync/commonspace/settings/settingsstate"
|
||||
gomock "github.com/golang/mock/gomock"
|
||||
)
|
||||
|
||||
@@ -35,20 +35,6 @@ func (m *MockDiffSyncer) EXPECT() *MockDiffSyncerMockRecorder {
|
||||
return m.recorder
|
||||
}
|
||||
|
||||
// Close mocks base method.
|
||||
func (m *MockDiffSyncer) Close() error {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "Close")
|
||||
ret0, _ := ret[0].(error)
|
||||
return ret0
|
||||
}
|
||||
|
||||
// Close indicates an expected call of Close.
|
||||
func (mr *MockDiffSyncerMockRecorder) Close() *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Close", reflect.TypeOf((*MockDiffSyncer)(nil).Close))
|
||||
}
|
||||
|
||||
// Init mocks base method.
|
||||
func (m *MockDiffSyncer) Init(arg0 settingsstate.ObjectDeletionState) {
|
||||
m.ctrl.T.Helper()
|
||||
|
||||
@@ -2,8 +2,8 @@ package headsync
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/anyproto/any-sync/app/ldiff"
|
||||
"github.com/anyproto/any-sync/commonspace/spacesyncproto"
|
||||
"github.com/anytypeio/any-sync/app/ldiff"
|
||||
"github.com/anytypeio/any-sync/commonspace/spacesyncproto"
|
||||
)
|
||||
|
||||
type Client interface {
|
||||
|
||||
@@ -3,8 +3,8 @@ package headsync
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"github.com/anyproto/any-sync/app/ldiff"
|
||||
"github.com/anyproto/any-sync/commonspace/spacesyncproto"
|
||||
"github.com/anytypeio/any-sync/app/ldiff"
|
||||
"github.com/anytypeio/any-sync/commonspace/spacesyncproto"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
"testing"
|
||||
|
||||
@@ -2,7 +2,7 @@ package accountdata
|
||||
|
||||
import (
|
||||
"crypto/rand"
|
||||
"github.com/anyproto/any-sync/util/crypto"
|
||||
"github.com/anytypeio/any-sync/util/crypto"
|
||||
)
|
||||
|
||||
type AccountKeys struct {
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
package list
|
||||
|
||||
import (
|
||||
"github.com/anyproto/any-sync/commonspace/object/acl/aclrecordproto"
|
||||
"github.com/anyproto/any-sync/util/cidutil"
|
||||
"github.com/anyproto/any-sync/util/crypto"
|
||||
"github.com/anytypeio/any-sync/commonspace/object/acl/aclrecordproto"
|
||||
"github.com/anytypeio/any-sync/util/cidutil"
|
||||
"github.com/anytypeio/any-sync/util/crypto"
|
||||
"github.com/gogo/protobuf/proto"
|
||||
"time"
|
||||
)
|
||||
|
||||
@@ -3,9 +3,9 @@ package list
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"github.com/anyproto/any-sync/app/logger"
|
||||
"github.com/anyproto/any-sync/commonspace/object/acl/aclrecordproto"
|
||||
"github.com/anyproto/any-sync/util/crypto"
|
||||
"github.com/anytypeio/any-sync/app/logger"
|
||||
"github.com/anytypeio/any-sync/commonspace/object/acl/aclrecordproto"
|
||||
"github.com/anytypeio/any-sync/util/crypto"
|
||||
"github.com/gogo/protobuf/proto"
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package list
|
||||
|
||||
import (
|
||||
"github.com/anyproto/any-sync/commonspace/object/accountdata"
|
||||
"github.com/anyproto/any-sync/util/crypto"
|
||||
"github.com/anytypeio/any-sync/commonspace/object/accountdata"
|
||||
"github.com/anytypeio/any-sync/util/crypto"
|
||||
)
|
||||
|
||||
type aclStateBuilder struct {
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
//go:generate mockgen -destination mock_list/mock_list.go github.com/anyproto/any-sync/commonspace/object/acl/list AclList
|
||||
//go:generate mockgen -destination mock_list/mock_list.go github.com/anytypeio/any-sync/commonspace/object/acl/list AclList
|
||||
package list
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"github.com/anyproto/any-sync/commonspace/object/accountdata"
|
||||
"github.com/anyproto/any-sync/commonspace/object/acl/aclrecordproto"
|
||||
"github.com/anyproto/any-sync/commonspace/object/acl/liststorage"
|
||||
"github.com/anyproto/any-sync/util/crypto"
|
||||
"github.com/anytypeio/any-sync/commonspace/object/accountdata"
|
||||
"github.com/anytypeio/any-sync/commonspace/object/acl/aclrecordproto"
|
||||
"github.com/anytypeio/any-sync/commonspace/object/acl/liststorage"
|
||||
"github.com/anytypeio/any-sync/util/crypto"
|
||||
"sync"
|
||||
)
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ package list
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/anyproto/any-sync/commonspace/object/accountdata"
|
||||
"github.com/anytypeio/any-sync/commonspace/object/accountdata"
|
||||
"github.com/stretchr/testify/require"
|
||||
"testing"
|
||||
)
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
package list
|
||||
|
||||
import (
|
||||
"github.com/anyproto/any-sync/commonspace/object/accountdata"
|
||||
"github.com/anyproto/any-sync/commonspace/object/acl/aclrecordproto"
|
||||
"github.com/anyproto/any-sync/commonspace/object/acl/liststorage"
|
||||
"github.com/anyproto/any-sync/util/crypto"
|
||||
"github.com/anytypeio/any-sync/commonspace/object/accountdata"
|
||||
"github.com/anytypeio/any-sync/commonspace/object/acl/aclrecordproto"
|
||||
"github.com/anytypeio/any-sync/commonspace/object/acl/liststorage"
|
||||
"github.com/anytypeio/any-sync/util/crypto"
|
||||
)
|
||||
|
||||
func NewTestDerivedAcl(spaceId string, keys *accountdata.AccountKeys) (AclList, error) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// Code generated by MockGen. DO NOT EDIT.
|
||||
// Source: github.com/anyproto/any-sync/commonspace/object/acl/list (interfaces: AclList)
|
||||
// Source: github.com/anytypeio/any-sync/commonspace/object/acl/list (interfaces: AclList)
|
||||
|
||||
// Package mock_list is a generated GoMock package.
|
||||
package mock_list
|
||||
@@ -7,9 +7,9 @@ package mock_list
|
||||
import (
|
||||
reflect "reflect"
|
||||
|
||||
aclrecordproto "github.com/anyproto/any-sync/commonspace/object/acl/aclrecordproto"
|
||||
list "github.com/anyproto/any-sync/commonspace/object/acl/list"
|
||||
crypto "github.com/anyproto/any-sync/util/crypto"
|
||||
aclrecordproto "github.com/anytypeio/any-sync/commonspace/object/acl/aclrecordproto"
|
||||
list "github.com/anytypeio/any-sync/commonspace/object/acl/list"
|
||||
crypto "github.com/anytypeio/any-sync/util/crypto"
|
||||
gomock "github.com/golang/mock/gomock"
|
||||
)
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package list
|
||||
|
||||
import (
|
||||
"github.com/anyproto/any-sync/commonspace/object/acl/aclrecordproto"
|
||||
"github.com/anyproto/any-sync/util/crypto"
|
||||
"github.com/anytypeio/any-sync/commonspace/object/acl/aclrecordproto"
|
||||
"github.com/anytypeio/any-sync/util/crypto"
|
||||
)
|
||||
|
||||
type AclRecord struct {
|
||||
|
||||
@@ -3,7 +3,7 @@ package liststorage
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"github.com/anyproto/any-sync/commonspace/object/acl/aclrecordproto"
|
||||
"github.com/anytypeio/any-sync/commonspace/object/acl/aclrecordproto"
|
||||
"sync"
|
||||
)
|
||||
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
//go:generate mockgen -destination mock_liststorage/mock_liststorage.go github.com/anyproto/any-sync/commonspace/object/acl/liststorage ListStorage
|
||||
//go:generate mockgen -destination mock_liststorage/mock_liststorage.go github.com/anytypeio/any-sync/commonspace/object/acl/liststorage ListStorage
|
||||
package liststorage
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"github.com/anyproto/any-sync/commonspace/object/acl/aclrecordproto"
|
||||
"github.com/anytypeio/any-sync/commonspace/object/acl/aclrecordproto"
|
||||
)
|
||||
|
||||
var (
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// Code generated by MockGen. DO NOT EDIT.
|
||||
// Source: github.com/anyproto/any-sync/commonspace/object/acl/liststorage (interfaces: ListStorage)
|
||||
// Source: github.com/anytypeio/any-sync/commonspace/object/acl/liststorage (interfaces: ListStorage)
|
||||
|
||||
// Package mock_liststorage is a generated GoMock package.
|
||||
package mock_liststorage
|
||||
@@ -8,7 +8,7 @@ import (
|
||||
context "context"
|
||||
reflect "reflect"
|
||||
|
||||
aclrecordproto "github.com/anyproto/any-sync/commonspace/object/acl/aclrecordproto"
|
||||
aclrecordproto "github.com/anytypeio/any-sync/commonspace/object/acl/aclrecordproto"
|
||||
gomock "github.com/golang/mock/gomock"
|
||||
)
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
package syncacl
|
||||
|
||||
import (
|
||||
"github.com/anyproto/any-sync/commonspace/object/acl/list"
|
||||
"github.com/anyproto/any-sync/commonspace/objectsync"
|
||||
"github.com/anyproto/any-sync/commonspace/objectsync/synchandler"
|
||||
"github.com/anytypeio/any-sync/commonspace/object/acl/list"
|
||||
"github.com/anytypeio/any-sync/commonspace/objectsync"
|
||||
"github.com/anytypeio/any-sync/commonspace/objectsync/synchandler"
|
||||
)
|
||||
|
||||
type SyncAcl struct {
|
||||
|
||||
@@ -3,9 +3,9 @@ package syncacl
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"github.com/anyproto/any-sync/commonspace/object/acl/aclrecordproto"
|
||||
"github.com/anyproto/any-sync/commonspace/object/acl/list"
|
||||
"github.com/anyproto/any-sync/commonspace/spacesyncproto"
|
||||
"github.com/anytypeio/any-sync/commonspace/object/acl/aclrecordproto"
|
||||
"github.com/anytypeio/any-sync/commonspace/object/acl/list"
|
||||
"github.com/anytypeio/any-sync/commonspace/spacesyncproto"
|
||||
)
|
||||
|
||||
type syncAclHandler struct {
|
||||
|
||||
@@ -2,7 +2,7 @@ package syncobjectgetter
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/anyproto/any-sync/commonspace/objectsync/synchandler"
|
||||
"github.com/anytypeio/any-sync/commonspace/objectsync/synchandler"
|
||||
)
|
||||
|
||||
type SyncObject interface {
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
package exporter
|
||||
|
||||
import (
|
||||
"github.com/anyproto/any-sync/commonspace/object/acl/liststorage"
|
||||
"github.com/anyproto/any-sync/commonspace/object/tree/objecttree"
|
||||
"github.com/anyproto/any-sync/commonspace/object/tree/treechangeproto"
|
||||
"github.com/anyproto/any-sync/commonspace/object/tree/treestorage"
|
||||
"github.com/anyproto/any-sync/util/crypto"
|
||||
"github.com/anytypeio/any-sync/commonspace/object/acl/liststorage"
|
||||
"github.com/anytypeio/any-sync/commonspace/object/tree/objecttree"
|
||||
"github.com/anytypeio/any-sync/commonspace/object/tree/treechangeproto"
|
||||
"github.com/anytypeio/any-sync/commonspace/object/tree/treestorage"
|
||||
"github.com/anytypeio/any-sync/util/crypto"
|
||||
)
|
||||
|
||||
type DataConverter interface {
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
package exporter
|
||||
|
||||
import (
|
||||
"github.com/anyproto/any-sync/commonspace/object/acl/list"
|
||||
"github.com/anyproto/any-sync/commonspace/object/acl/liststorage"
|
||||
"github.com/anyproto/any-sync/commonspace/object/tree/objecttree"
|
||||
"github.com/anyproto/any-sync/commonspace/object/tree/treestorage"
|
||||
"github.com/anytypeio/any-sync/commonspace/object/acl/list"
|
||||
"github.com/anytypeio/any-sync/commonspace/object/acl/liststorage"
|
||||
"github.com/anytypeio/any-sync/commonspace/object/tree/objecttree"
|
||||
"github.com/anytypeio/any-sync/commonspace/object/tree/treestorage"
|
||||
)
|
||||
|
||||
type TreeImportParams struct {
|
||||
|
||||
@@ -2,8 +2,8 @@ package objecttree
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"github.com/anyproto/any-sync/commonspace/object/tree/treechangeproto"
|
||||
"github.com/anyproto/any-sync/util/crypto"
|
||||
"github.com/anytypeio/any-sync/commonspace/object/tree/treechangeproto"
|
||||
"github.com/anytypeio/any-sync/util/crypto"
|
||||
"github.com/gogo/protobuf/proto"
|
||||
)
|
||||
|
||||
|
||||
@@ -2,9 +2,9 @@ package objecttree
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"github.com/anyproto/any-sync/commonspace/object/tree/treechangeproto"
|
||||
"github.com/anyproto/any-sync/util/cidutil"
|
||||
"github.com/anyproto/any-sync/util/crypto"
|
||||
"github.com/anytypeio/any-sync/commonspace/object/tree/treechangeproto"
|
||||
"github.com/anytypeio/any-sync/util/cidutil"
|
||||
"github.com/anytypeio/any-sync/util/crypto"
|
||||
"github.com/gogo/protobuf/proto"
|
||||
)
|
||||
|
||||
|
||||
@@ -14,47 +14,34 @@ type historyTree struct {
|
||||
*objectTree
|
||||
}
|
||||
|
||||
func (h *historyTree) rebuildFromStorage(params HistoryTreeParams) (err error) {
|
||||
err = h.rebuild(params)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
h.aclList.RLock()
|
||||
defer h.aclList.RUnlock()
|
||||
state := h.aclList.AclState()
|
||||
|
||||
return h.readKeysFromAclState(state)
|
||||
}
|
||||
|
||||
func (h *historyTree) rebuild(params HistoryTreeParams) (err error) {
|
||||
var (
|
||||
beforeId = params.BeforeId
|
||||
include = params.IncludeBeforeId
|
||||
full = params.BuildFullTree
|
||||
)
|
||||
h.treeBuilder.Reset()
|
||||
if full {
|
||||
h.tree, err = h.treeBuilder.BuildFull()
|
||||
return
|
||||
}
|
||||
if beforeId == h.Id() && !include {
|
||||
func (h *historyTree) rebuildFromStorage(beforeId string, include bool) (err error) {
|
||||
ot := h.objectTree
|
||||
ot.treeBuilder.Reset()
|
||||
if beforeId == ot.Id() && !include {
|
||||
return ErrLoadBeforeRoot
|
||||
}
|
||||
|
||||
heads := []string{beforeId}
|
||||
if beforeId == "" {
|
||||
heads, err = h.treeStorage.Heads()
|
||||
heads, err = ot.treeStorage.Heads()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
} else if !include {
|
||||
beforeChange, err := h.treeBuilder.loadChange(beforeId)
|
||||
beforeChange, err := ot.treeBuilder.loadChange(beforeId)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
heads = beforeChange.PreviousIds
|
||||
}
|
||||
|
||||
h.tree, err = h.treeBuilder.build(heads, nil, nil)
|
||||
return
|
||||
ot.tree, err = ot.treeBuilder.build(heads, nil, nil)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
ot.aclList.RLock()
|
||||
defer ot.aclList.RUnlock()
|
||||
state := ot.aclList.AclState()
|
||||
|
||||
return ot.readKeysFromAclState(state)
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
// Code generated by MockGen. DO NOT EDIT.
|
||||
// Source: github.com/anyproto/any-sync/commonspace/object/tree/objecttree (interfaces: ObjectTree)
|
||||
// Source: github.com/anytypeio/any-sync/commonspace/object/tree/objecttree (interfaces: ObjectTree)
|
||||
|
||||
// Package mock_objecttree is a generated GoMock package.
|
||||
package mock_objecttree
|
||||
@@ -9,10 +9,10 @@ import (
|
||||
reflect "reflect"
|
||||
time "time"
|
||||
|
||||
list "github.com/anyproto/any-sync/commonspace/object/acl/list"
|
||||
objecttree "github.com/anyproto/any-sync/commonspace/object/tree/objecttree"
|
||||
treechangeproto "github.com/anyproto/any-sync/commonspace/object/tree/treechangeproto"
|
||||
treestorage "github.com/anyproto/any-sync/commonspace/object/tree/treestorage"
|
||||
list "github.com/anytypeio/any-sync/commonspace/object/acl/list"
|
||||
objecttree "github.com/anytypeio/any-sync/commonspace/object/tree/objecttree"
|
||||
treechangeproto "github.com/anytypeio/any-sync/commonspace/object/tree/treechangeproto"
|
||||
treestorage "github.com/anytypeio/any-sync/commonspace/object/tree/treestorage"
|
||||
gomock "github.com/golang/mock/gomock"
|
||||
)
|
||||
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
//go:generate mockgen -destination mock_objecttree/mock_objecttree.go github.com/anyproto/any-sync/commonspace/object/tree/objecttree ObjectTree
|
||||
//go:generate mockgen -destination mock_objecttree/mock_objecttree.go github.com/anytypeio/any-sync/commonspace/object/tree/objecttree ObjectTree
|
||||
package objecttree
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"github.com/anyproto/any-sync/util/crypto"
|
||||
"github.com/anytypeio/any-sync/util/crypto"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/anyproto/any-sync/commonspace/object/acl/aclrecordproto"
|
||||
"github.com/anyproto/any-sync/commonspace/object/acl/list"
|
||||
"github.com/anyproto/any-sync/commonspace/object/tree/treechangeproto"
|
||||
"github.com/anyproto/any-sync/commonspace/object/tree/treestorage"
|
||||
"github.com/anyproto/any-sync/util/slice"
|
||||
"github.com/anytypeio/any-sync/commonspace/object/acl/aclrecordproto"
|
||||
"github.com/anytypeio/any-sync/commonspace/object/acl/list"
|
||||
"github.com/anytypeio/any-sync/commonspace/object/tree/treechangeproto"
|
||||
"github.com/anytypeio/any-sync/commonspace/object/tree/treestorage"
|
||||
"github.com/anytypeio/any-sync/util/slice"
|
||||
)
|
||||
|
||||
type RWLocker interface {
|
||||
@@ -116,25 +116,13 @@ type objectTree struct {
|
||||
}
|
||||
|
||||
func (ot *objectTree) rebuildFromStorage(theirHeads []string, newChanges []*Change) (err error) {
|
||||
oldTree := ot.tree
|
||||
ot.treeBuilder.Reset()
|
||||
|
||||
ot.tree, err = ot.treeBuilder.Build(theirHeads, newChanges)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
// in case there are new heads
|
||||
if theirHeads != nil && oldTree != nil {
|
||||
// checking that old root is still in tree
|
||||
rootCh, rootExists := ot.tree.attached[oldTree.RootId()]
|
||||
|
||||
// checking the case where theirHeads were actually below prevHeads
|
||||
// so if we did load some extra data in the tree, let's reduce it to old root
|
||||
if slice.UnsortedEquals(oldTree.headIds, ot.tree.headIds) && rootExists && ot.tree.RootId() != oldTree.RootId() {
|
||||
ot.tree.makeRootAndRemove(rootCh)
|
||||
}
|
||||
}
|
||||
|
||||
// during building the tree we may have marked some changes as possible roots,
|
||||
// but obviously they are not roots, because of the way how we construct the tree
|
||||
ot.tree.clearPossibleRoots()
|
||||
@@ -199,7 +187,7 @@ func (ot *objectTree) AddContent(ctx context.Context, content SignableChangeCont
|
||||
panic(err)
|
||||
}
|
||||
|
||||
err = ot.treeStorage.AddRawChangesSetHeads([]*treechangeproto.RawTreeChangeWithId{rawChange}, []string{objChange.Id})
|
||||
err = ot.treeStorage.TransactionAdd([]*treechangeproto.RawTreeChangeWithId{rawChange}, []string{objChange.Id})
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
@@ -296,11 +284,7 @@ func (ot *objectTree) AddRawChanges(ctx context.Context, changesPayload RawChang
|
||||
addResult.Mode = Rebuild
|
||||
}
|
||||
|
||||
err = ot.treeStorage.AddRawChangesSetHeads(addResult.Added, addResult.Heads)
|
||||
if err != nil {
|
||||
// rolling back all changes made to inmemory state
|
||||
ot.rebuildFromStorage(nil, nil)
|
||||
}
|
||||
err = ot.treeStorage.TransactionAdd(addResult.Added, addResult.Heads)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -363,7 +347,7 @@ func (ot *objectTree) addRawChanges(ctx context.Context, changesPayload RawChang
|
||||
}
|
||||
|
||||
// checks if we need to go to database
|
||||
snapshotNotInTree := func(ch *Change) bool {
|
||||
isOldSnapshot := func(ch *Change) bool {
|
||||
if ch.SnapshotId == ot.tree.RootId() {
|
||||
return false
|
||||
}
|
||||
@@ -378,12 +362,26 @@ func (ot *objectTree) addRawChanges(ctx context.Context, changesPayload RawChang
|
||||
|
||||
shouldRebuildFromStorage := false
|
||||
// checking if we have some changes with different snapshot and then rebuilding
|
||||
for _, ch := range ot.newChangesBuf {
|
||||
if snapshotNotInTree(ch) {
|
||||
for idx, ch := range ot.newChangesBuf {
|
||||
if isOldSnapshot(ch) {
|
||||
var exists bool
|
||||
// checking if it exists in the storage, if yes, then at some point it was added to the tree
|
||||
// thus we don't need to look at this change
|
||||
exists, err = ot.treeStorage.HasChange(ctx, ch.Id)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
if exists {
|
||||
// marking as nil to delete after
|
||||
ot.newChangesBuf[idx] = nil
|
||||
continue
|
||||
}
|
||||
// we haven't seen the change, and it refers to old snapshot, so we should rebuild
|
||||
shouldRebuildFromStorage = true
|
||||
break
|
||||
}
|
||||
}
|
||||
// discarding all previously seen changes
|
||||
ot.newChangesBuf = slice.DiscardFromSlice(ot.newChangesBuf, func(ch *Change) bool { return ch == nil })
|
||||
|
||||
if shouldRebuildFromStorage {
|
||||
err = ot.rebuildFromStorage(changesPayload.NewHeads, ot.newChangesBuf)
|
||||
@@ -551,8 +549,22 @@ func (ot *objectTree) IterateFrom(id string, convert ChangeConvertFunc, iterate
|
||||
}
|
||||
|
||||
func (ot *objectTree) HasChanges(chs ...string) bool {
|
||||
hasChange := func(s string) bool {
|
||||
_, attachedExists := ot.tree.attached[s]
|
||||
if attachedExists {
|
||||
return attachedExists
|
||||
}
|
||||
|
||||
has, err := ot.treeStorage.HasChange(context.Background(), s)
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
|
||||
return has
|
||||
}
|
||||
|
||||
for _, ch := range chs {
|
||||
if _, attachedExists := ot.tree.attached[ch]; !attachedExists {
|
||||
if !hasChange(ch) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,11 +2,10 @@ package objecttree
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"github.com/anyproto/any-sync/commonspace/object/accountdata"
|
||||
"github.com/anyproto/any-sync/commonspace/object/acl/list"
|
||||
"github.com/anyproto/any-sync/commonspace/object/tree/treechangeproto"
|
||||
"github.com/anyproto/any-sync/commonspace/object/tree/treestorage"
|
||||
"github.com/anytypeio/any-sync/commonspace/object/accountdata"
|
||||
"github.com/anytypeio/any-sync/commonspace/object/acl/list"
|
||||
"github.com/anytypeio/any-sync/commonspace/object/tree/treechangeproto"
|
||||
"github.com/anytypeio/any-sync/commonspace/object/tree/treestorage"
|
||||
"github.com/gogo/protobuf/proto"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
@@ -65,7 +64,7 @@ func prepareContext(
|
||||
treeStorage := changeCreator.CreateNewTreeStorage("0", aclList.Head().Id)
|
||||
if additionalChanges != nil {
|
||||
payload := additionalChanges(changeCreator)
|
||||
err := treeStorage.AddRawChangesSetHeads(payload.RawChanges, payload.NewHeads)
|
||||
err := treeStorage.TransactionAdd(payload.RawChanges, payload.NewHeads)
|
||||
require.NoError(t, err)
|
||||
}
|
||||
objTree, err := objTreeBuilder(treeStorage, aclList)
|
||||
@@ -422,99 +421,6 @@ func TestObjectTree(t *testing.T) {
|
||||
})
|
||||
})
|
||||
|
||||
t.Run("rollback when add to storage returns error", func(t *testing.T) {
|
||||
ctx := prepareTreeContext(t, aclList)
|
||||
changeCreator := ctx.changeCreator
|
||||
objTree := ctx.objTree
|
||||
store := ctx.treeStorage.(*treestorage.InMemoryTreeStorage)
|
||||
addErr := fmt.Errorf("error saving")
|
||||
store.SetReturnErrorOnAdd(addErr)
|
||||
|
||||
rawChanges := []*treechangeproto.RawTreeChangeWithId{
|
||||
changeCreator.CreateRaw("1", aclList.Head().Id, "0", true, "0"),
|
||||
}
|
||||
payload := RawChangesPayload{
|
||||
NewHeads: []string{"1"},
|
||||
RawChanges: rawChanges,
|
||||
}
|
||||
_, err := objTree.AddRawChanges(context.Background(), payload)
|
||||
require.Error(t, err, addErr)
|
||||
require.Equal(t, "0", objTree.Root().Id)
|
||||
})
|
||||
|
||||
t.Run("their heads before common snapshot", func(t *testing.T) {
|
||||
// checking that adding old changes did not affect the tree
|
||||
ctx := prepareTreeContext(t, aclList)
|
||||
changeCreator := ctx.changeCreator
|
||||
objTree := ctx.objTree
|
||||
|
||||
rawChanges := []*treechangeproto.RawTreeChangeWithId{
|
||||
changeCreator.CreateRaw("1", aclList.Head().Id, "0", true, "0"),
|
||||
changeCreator.CreateRaw("2", aclList.Head().Id, "1", false, "1"),
|
||||
changeCreator.CreateRaw("3", aclList.Head().Id, "1", true, "2"),
|
||||
changeCreator.CreateRaw("4", aclList.Head().Id, "1", false, "2"),
|
||||
changeCreator.CreateRaw("5", aclList.Head().Id, "1", false, "1"),
|
||||
changeCreator.CreateRaw("6", aclList.Head().Id, "1", true, "3", "4", "5"),
|
||||
}
|
||||
payload := RawChangesPayload{
|
||||
NewHeads: []string{rawChanges[len(rawChanges)-1].Id},
|
||||
RawChanges: rawChanges,
|
||||
}
|
||||
_, err := objTree.AddRawChanges(context.Background(), payload)
|
||||
require.NoError(t, err, "adding changes should be without error")
|
||||
require.Equal(t, "6", objTree.Root().Id)
|
||||
|
||||
rawChangesPrevious := []*treechangeproto.RawTreeChangeWithId{
|
||||
changeCreator.CreateRaw("1", aclList.Head().Id, "0", true, "0"),
|
||||
}
|
||||
payload = RawChangesPayload{
|
||||
NewHeads: []string{"1"},
|
||||
RawChanges: rawChangesPrevious,
|
||||
}
|
||||
_, err = objTree.AddRawChanges(context.Background(), payload)
|
||||
require.NoError(t, err, "adding changes should be without error")
|
||||
require.Equal(t, "6", objTree.Root().Id)
|
||||
})
|
||||
|
||||
t.Run("stored changes will not break the pipeline if heads were not updated", func(t *testing.T) {
|
||||
ctx := prepareTreeContext(t, aclList)
|
||||
changeCreator := ctx.changeCreator
|
||||
objTree := ctx.objTree
|
||||
store := ctx.treeStorage.(*treestorage.InMemoryTreeStorage)
|
||||
|
||||
rawChanges := []*treechangeproto.RawTreeChangeWithId{
|
||||
changeCreator.CreateRaw("1", aclList.Head().Id, "0", true, "0"),
|
||||
}
|
||||
payload := RawChangesPayload{
|
||||
NewHeads: []string{rawChanges[len(rawChanges)-1].Id},
|
||||
RawChanges: rawChanges,
|
||||
}
|
||||
_, err := objTree.AddRawChanges(context.Background(), payload)
|
||||
require.NoError(t, err, "adding changes should be without error")
|
||||
require.Equal(t, "1", objTree.Root().Id)
|
||||
|
||||
// creating changes to save in the storage
|
||||
// to imitate the condition where all changes are in the storage
|
||||
// but the head was not updated
|
||||
storageChanges := []*treechangeproto.RawTreeChangeWithId{
|
||||
changeCreator.CreateRaw("2", aclList.Head().Id, "1", false, "1"),
|
||||
changeCreator.CreateRaw("3", aclList.Head().Id, "1", true, "2"),
|
||||
changeCreator.CreateRaw("4", aclList.Head().Id, "1", false, "2"),
|
||||
changeCreator.CreateRaw("5", aclList.Head().Id, "1", false, "1"),
|
||||
changeCreator.CreateRaw("6", aclList.Head().Id, "1", true, "3", "4", "5"),
|
||||
}
|
||||
store.AddRawChangesSetHeads(storageChanges, []string{"1"})
|
||||
|
||||
// updating with subset of those changes to see that everything will still work
|
||||
payload = RawChangesPayload{
|
||||
NewHeads: []string{"6"},
|
||||
RawChanges: storageChanges,
|
||||
}
|
||||
_, err = objTree.AddRawChanges(context.Background(), payload)
|
||||
require.NoError(t, err, "adding changes should be without error")
|
||||
require.Equal(t, "6", objTree.Root().Id)
|
||||
})
|
||||
|
||||
t.Run("changes from tree after common snapshot complex", func(t *testing.T) {
|
||||
ctx := prepareTreeContext(t, aclList)
|
||||
changeCreator := ctx.changeCreator
|
||||
@@ -748,7 +654,7 @@ func TestObjectTree(t *testing.T) {
|
||||
changeCreator.CreateRaw("5", aclList.Head().Id, "0", false, "1"),
|
||||
changeCreator.CreateRaw("6", aclList.Head().Id, "0", false, "3", "4", "5"),
|
||||
}
|
||||
deps.treeStorage.AddRawChangesSetHeads(rawChanges, []string{"6"})
|
||||
deps.treeStorage.TransactionAdd(rawChanges, []string{"6"})
|
||||
hTree, err := buildHistoryTree(deps, HistoryTreeParams{
|
||||
BeforeId: "6",
|
||||
IncludeBeforeId: false,
|
||||
@@ -768,37 +674,6 @@ func TestObjectTree(t *testing.T) {
|
||||
assert.Equal(t, "0", hTree.Root().Id)
|
||||
})
|
||||
|
||||
t.Run("test history tree build full", func(t *testing.T) {
|
||||
changeCreator, deps := prepareHistoryTreeDeps(aclList)
|
||||
|
||||
// sequence of snapshots: 5->1->0
|
||||
rawChanges := []*treechangeproto.RawTreeChangeWithId{
|
||||
changeCreator.CreateRaw("1", aclList.Head().Id, "0", true, "0"),
|
||||
changeCreator.CreateRaw("2", aclList.Head().Id, "1", false, "1"),
|
||||
changeCreator.CreateRaw("3", aclList.Head().Id, "1", true, "2"),
|
||||
changeCreator.CreateRaw("4", aclList.Head().Id, "1", false, "2"),
|
||||
changeCreator.CreateRaw("5", aclList.Head().Id, "1", true, "3", "4"),
|
||||
changeCreator.CreateRaw("6", aclList.Head().Id, "5", false, "5"),
|
||||
}
|
||||
deps.treeStorage.AddRawChangesSetHeads(rawChanges, []string{"6"})
|
||||
hTree, err := buildHistoryTree(deps, HistoryTreeParams{
|
||||
BuildFullTree: true,
|
||||
})
|
||||
require.NoError(t, err)
|
||||
// check tree heads
|
||||
assert.Equal(t, []string{"6"}, hTree.Heads())
|
||||
|
||||
// check tree iterate
|
||||
var iterChangesId []string
|
||||
err = hTree.IterateFrom(hTree.Root().Id, nil, func(change *Change) bool {
|
||||
iterChangesId = append(iterChangesId, change.Id)
|
||||
return true
|
||||
})
|
||||
require.NoError(t, err, "iterate should be without error")
|
||||
assert.Equal(t, []string{"0", "1", "2", "3", "4", "5", "6"}, iterChangesId)
|
||||
assert.Equal(t, "0", hTree.Root().Id)
|
||||
})
|
||||
|
||||
t.Run("test history tree include", func(t *testing.T) {
|
||||
changeCreator, deps := prepareHistoryTreeDeps(aclList)
|
||||
|
||||
@@ -810,7 +685,7 @@ func TestObjectTree(t *testing.T) {
|
||||
changeCreator.CreateRaw("5", aclList.Head().Id, "0", false, "1"),
|
||||
changeCreator.CreateRaw("6", aclList.Head().Id, "0", false, "3", "4", "5"),
|
||||
}
|
||||
deps.treeStorage.AddRawChangesSetHeads(rawChanges, []string{"6"})
|
||||
deps.treeStorage.TransactionAdd(rawChanges, []string{"6"})
|
||||
hTree, err := buildHistoryTree(deps, HistoryTreeParams{
|
||||
BeforeId: "6",
|
||||
IncludeBeforeId: true,
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
package objecttree
|
||||
|
||||
import (
|
||||
"github.com/anyproto/any-sync/commonspace/object/acl/list"
|
||||
"github.com/anyproto/any-sync/commonspace/object/tree/treechangeproto"
|
||||
"github.com/anyproto/any-sync/commonspace/object/tree/treestorage"
|
||||
"github.com/anyproto/any-sync/util/crypto"
|
||||
"github.com/anytypeio/any-sync/commonspace/object/acl/list"
|
||||
"github.com/anytypeio/any-sync/commonspace/object/tree/treechangeproto"
|
||||
"github.com/anytypeio/any-sync/commonspace/object/tree/treestorage"
|
||||
"github.com/anytypeio/any-sync/util/crypto"
|
||||
)
|
||||
|
||||
type ObjectTreeCreatePayload struct {
|
||||
@@ -22,7 +22,6 @@ type HistoryTreeParams struct {
|
||||
AclList list.AclList
|
||||
BeforeId string
|
||||
IncludeBeforeId bool
|
||||
BuildFullTree bool
|
||||
}
|
||||
|
||||
type objectTreeDeps struct {
|
||||
@@ -231,7 +230,7 @@ func buildHistoryTree(deps objectTreeDeps, params HistoryTreeParams) (ht History
|
||||
}
|
||||
|
||||
hTree := &historyTree{objectTree: objTree}
|
||||
err = hTree.rebuildFromStorage(params)
|
||||
err = hTree.rebuildFromStorage(params.BeforeId, params.IncludeBeforeId)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -3,10 +3,10 @@ package objecttree
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"github.com/anyproto/any-sync/commonspace/object/acl/aclrecordproto"
|
||||
"github.com/anyproto/any-sync/commonspace/object/acl/list"
|
||||
"github.com/anyproto/any-sync/commonspace/object/tree/treestorage"
|
||||
"github.com/anyproto/any-sync/util/slice"
|
||||
"github.com/anytypeio/any-sync/commonspace/object/acl/aclrecordproto"
|
||||
"github.com/anytypeio/any-sync/commonspace/object/acl/list"
|
||||
"github.com/anytypeio/any-sync/commonspace/object/tree/treestorage"
|
||||
"github.com/anytypeio/any-sync/util/slice"
|
||||
)
|
||||
|
||||
type ObjectTreeValidator interface {
|
||||
|
||||
@@ -2,9 +2,9 @@ package objecttree
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/anyproto/any-sync/commonspace/object/tree/treechangeproto"
|
||||
"github.com/anyproto/any-sync/commonspace/object/tree/treestorage"
|
||||
"github.com/anyproto/any-sync/util/slice"
|
||||
"github.com/anytypeio/any-sync/commonspace/object/tree/treechangeproto"
|
||||
"github.com/anytypeio/any-sync/commonspace/object/tree/treestorage"
|
||||
"github.com/anytypeio/any-sync/util/slice"
|
||||
"time"
|
||||
)
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package objecttree
|
||||
|
||||
import (
|
||||
"github.com/anyproto/any-sync/util/crypto"
|
||||
"github.com/anytypeio/any-sync/util/crypto"
|
||||
)
|
||||
|
||||
// SignableChangeContent is a payload to be passed when we are creating change
|
||||
|
||||
@@ -2,9 +2,9 @@ package objecttree
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/anyproto/any-sync/commonspace/object/tree/treechangeproto"
|
||||
"github.com/anyproto/any-sync/commonspace/object/tree/treestorage"
|
||||
"github.com/anyproto/any-sync/util/crypto"
|
||||
"github.com/anytypeio/any-sync/commonspace/object/tree/treechangeproto"
|
||||
"github.com/anytypeio/any-sync/commonspace/object/tree/treestorage"
|
||||
"github.com/anytypeio/any-sync/util/crypto"
|
||||
libcrypto "github.com/libp2p/go-libp2p/core/crypto"
|
||||
)
|
||||
|
||||
|
||||
@@ -6,9 +6,9 @@ import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/anyproto/any-sync/app/logger"
|
||||
"github.com/anyproto/any-sync/commonspace/object/tree/treestorage"
|
||||
"github.com/anyproto/any-sync/util/slice"
|
||||
"github.com/anytypeio/any-sync/app/logger"
|
||||
"github.com/anytypeio/any-sync/commonspace/object/tree/treestorage"
|
||||
"github.com/anytypeio/any-sync/util/slice"
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
@@ -51,22 +51,6 @@ func (tb *treeBuilder) Build(theirHeads []string, newChanges []*Change) (*Tree,
|
||||
return tb.build(heads, theirHeads, newChanges)
|
||||
}
|
||||
|
||||
func (tb *treeBuilder) BuildFull() (*Tree, error) {
|
||||
defer func() {
|
||||
tb.cache = make(map[string]*Change)
|
||||
}()
|
||||
tb.cache = make(map[string]*Change)
|
||||
heads, err := tb.treeStorage.Heads()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
err = tb.buildTree(heads, tb.treeStorage.Id())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return tb.tree, nil
|
||||
}
|
||||
|
||||
func (tb *treeBuilder) build(heads []string, theirHeads []string, newChanges []*Change) (*Tree, error) {
|
||||
defer func() {
|
||||
tb.cache = make(map[string]*Change)
|
||||
@@ -121,8 +105,8 @@ func (tb *treeBuilder) buildTree(heads []string, breakpoint string) (err error)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
changes := tb.dfs(heads, breakpoint)
|
||||
tb.tree.AddFast(ch)
|
||||
changes := tb.dfs(heads, breakpoint)
|
||||
tb.tree.AddFast(changes...)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ package objecttree
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/anyproto/any-sync/util/crypto"
|
||||
"github.com/anytypeio/any-sync/util/crypto"
|
||||
"math/rand"
|
||||
)
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// Code generated by MockGen. DO NOT EDIT.
|
||||
// Source: github.com/anyproto/any-sync/commonspace/object/tree/synctree (interfaces: SyncTree,ReceiveQueue,HeadNotifiable)
|
||||
// Source: github.com/anytypeio/any-sync/commonspace/object/tree/synctree (interfaces: SyncTree,ReceiveQueue,HeadNotifiable)
|
||||
|
||||
// Package mock_synctree is a generated GoMock package.
|
||||
package mock_synctree
|
||||
@@ -9,12 +9,12 @@ import (
|
||||
reflect "reflect"
|
||||
time "time"
|
||||
|
||||
list "github.com/anyproto/any-sync/commonspace/object/acl/list"
|
||||
objecttree "github.com/anyproto/any-sync/commonspace/object/tree/objecttree"
|
||||
updatelistener "github.com/anyproto/any-sync/commonspace/object/tree/synctree/updatelistener"
|
||||
treechangeproto "github.com/anyproto/any-sync/commonspace/object/tree/treechangeproto"
|
||||
treestorage "github.com/anyproto/any-sync/commonspace/object/tree/treestorage"
|
||||
spacesyncproto "github.com/anyproto/any-sync/commonspace/spacesyncproto"
|
||||
list "github.com/anytypeio/any-sync/commonspace/object/acl/list"
|
||||
objecttree "github.com/anytypeio/any-sync/commonspace/object/tree/objecttree"
|
||||
updatelistener "github.com/anytypeio/any-sync/commonspace/object/tree/synctree/updatelistener"
|
||||
treechangeproto "github.com/anytypeio/any-sync/commonspace/object/tree/treechangeproto"
|
||||
treestorage "github.com/anytypeio/any-sync/commonspace/object/tree/treestorage"
|
||||
spacesyncproto "github.com/anytypeio/any-sync/commonspace/spacesyncproto"
|
||||
gomock "github.com/golang/mock/gomock"
|
||||
)
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ package synctree
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"github.com/anyproto/any-sync/commonspace/object/tree/treechangeproto"
|
||||
"github.com/anytypeio/any-sync/commonspace/object/tree/treechangeproto"
|
||||
"sync"
|
||||
)
|
||||
|
||||
|
||||
@@ -2,12 +2,12 @@ package synctree
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/anyproto/any-sync/commonspace/object/accountdata"
|
||||
"github.com/anyproto/any-sync/commonspace/object/acl/list"
|
||||
"github.com/anyproto/any-sync/commonspace/object/tree/objecttree"
|
||||
"github.com/anyproto/any-sync/commonspace/object/tree/treechangeproto"
|
||||
"github.com/anyproto/any-sync/commonspace/object/tree/treestorage"
|
||||
"github.com/anyproto/any-sync/util/slice"
|
||||
"github.com/anytypeio/any-sync/commonspace/object/accountdata"
|
||||
"github.com/anytypeio/any-sync/commonspace/object/acl/list"
|
||||
"github.com/anytypeio/any-sync/commonspace/object/tree/objecttree"
|
||||
"github.com/anytypeio/any-sync/commonspace/object/tree/treechangeproto"
|
||||
"github.com/anytypeio/any-sync/commonspace/object/tree/treestorage"
|
||||
"github.com/anytypeio/any-sync/util/slice"
|
||||
"github.com/gogo/protobuf/proto"
|
||||
"github.com/stretchr/testify/require"
|
||||
"math/rand"
|
||||
@@ -112,7 +112,7 @@ func testTreeMerge(t *testing.T, levels, perLevel int, hasData bool, isSnapshot
|
||||
}
|
||||
// generating initial tree
|
||||
initialRes := genChanges(changeCreator, params)
|
||||
err = storage.AddRawChangesSetHeads(initialRes.changes, initialRes.heads)
|
||||
err = storage.TransactionAdd(initialRes.changes, initialRes.heads)
|
||||
require.NoError(t, err)
|
||||
deps := fixtureDeps{
|
||||
aclList: aclList,
|
||||
@@ -183,179 +183,3 @@ func testTreeMerge(t *testing.T, levels, perLevel int, hasData bool, isSnapshot
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestTreeStorageHasExtraChanges(t *testing.T) {
|
||||
var (
|
||||
rnd = rand.New(rand.NewSource(time.Now().Unix()))
|
||||
levels = 20
|
||||
perLevel = 40
|
||||
)
|
||||
|
||||
// simulating cases where one peer has some extra changes saved in storage
|
||||
// and checking that this will not break the sync
|
||||
t.Run("tree storage has extra simple", func(t *testing.T) {
|
||||
testTreeStorageHasExtra(t, levels, perLevel, false, func() bool {
|
||||
return false
|
||||
})
|
||||
testTreeStorageHasExtra(t, levels, perLevel, false, func() bool {
|
||||
return rnd.Intn(10) > 5
|
||||
})
|
||||
testTreeStorageHasExtra(t, levels, perLevel, true, func() bool {
|
||||
return false
|
||||
})
|
||||
testTreeStorageHasExtra(t, levels, perLevel, true, func() bool {
|
||||
return rnd.Intn(10) > 5
|
||||
})
|
||||
})
|
||||
t.Run("tree storage has extra three parts", func(t *testing.T) {
|
||||
testTreeStorageHasExtraThreeParts(t, levels, perLevel, false, func() bool {
|
||||
return false
|
||||
})
|
||||
testTreeStorageHasExtraThreeParts(t, levels, perLevel, false, func() bool {
|
||||
return rnd.Intn(10) > 5
|
||||
})
|
||||
testTreeStorageHasExtraThreeParts(t, levels, perLevel, true, func() bool {
|
||||
return false
|
||||
})
|
||||
testTreeStorageHasExtraThreeParts(t, levels, perLevel, true, func() bool {
|
||||
return rnd.Intn(10) > 5
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
func testTreeStorageHasExtra(t *testing.T, levels, perLevel int, hasData bool, isSnapshot func() bool) {
|
||||
treeId := "treeId"
|
||||
spaceId := "spaceId"
|
||||
keys, err := accountdata.NewRandom()
|
||||
require.NoError(t, err)
|
||||
aclList, err := list.NewTestDerivedAcl(spaceId, keys)
|
||||
storage := createStorage(treeId, aclList)
|
||||
changeCreator := objecttree.NewMockChangeCreator()
|
||||
builder := objecttree.BuildTestableTree
|
||||
if hasData {
|
||||
builder = objecttree.BuildEmptyDataTestableTree
|
||||
}
|
||||
params := genParams{
|
||||
prefix: "peer1",
|
||||
aclId: aclList.Id(),
|
||||
startIdx: 0,
|
||||
levels: levels,
|
||||
perLevel: perLevel,
|
||||
snapshotId: treeId,
|
||||
prevHeads: []string{treeId},
|
||||
isSnapshot: isSnapshot,
|
||||
hasData: hasData,
|
||||
}
|
||||
deps := fixtureDeps{
|
||||
aclList: aclList,
|
||||
initStorage: storage.(*treestorage.InMemoryTreeStorage),
|
||||
connectionMap: map[string][]string{
|
||||
"peer1": []string{"peer2"},
|
||||
"peer2": []string{"peer1"},
|
||||
},
|
||||
treeBuilder: builder,
|
||||
}
|
||||
fx := newProtocolFixture(t, spaceId, deps)
|
||||
|
||||
// generating initial tree
|
||||
initialRes := genChanges(changeCreator, params)
|
||||
fx.run(t)
|
||||
|
||||
// adding some changes to store, but without updating heads
|
||||
store := fx.handlers["peer1"].tree().Storage().(*treestorage.InMemoryTreeStorage)
|
||||
oldHeads, _ := store.Heads()
|
||||
store.AddRawChangesSetHeads(initialRes.changes, oldHeads)
|
||||
|
||||
// sending those changes to other peer
|
||||
fx.handlers["peer2"].sendRawChanges(context.Background(), objecttree.RawChangesPayload{
|
||||
NewHeads: initialRes.heads,
|
||||
RawChanges: initialRes.changes,
|
||||
})
|
||||
time.Sleep(50 * time.Millisecond)
|
||||
|
||||
// here we want that the saved changes in storage should not affect the sync protocol
|
||||
firstHeads := fx.handlers["peer1"].tree().Heads()
|
||||
secondHeads := fx.handlers["peer2"].tree().Heads()
|
||||
require.True(t, slice.UnsortedEquals(firstHeads, secondHeads))
|
||||
require.True(t, slice.UnsortedEquals(initialRes.heads, firstHeads))
|
||||
}
|
||||
|
||||
func testTreeStorageHasExtraThreeParts(t *testing.T, levels, perLevel int, hasData bool, isSnapshot func() bool) {
|
||||
treeId := "treeId"
|
||||
spaceId := "spaceId"
|
||||
keys, err := accountdata.NewRandom()
|
||||
require.NoError(t, err)
|
||||
aclList, err := list.NewTestDerivedAcl(spaceId, keys)
|
||||
storage := createStorage(treeId, aclList)
|
||||
changeCreator := objecttree.NewMockChangeCreator()
|
||||
builder := objecttree.BuildTestableTree
|
||||
if hasData {
|
||||
builder = objecttree.BuildEmptyDataTestableTree
|
||||
}
|
||||
params := genParams{
|
||||
prefix: "peer1",
|
||||
aclId: aclList.Id(),
|
||||
startIdx: 0,
|
||||
levels: levels,
|
||||
perLevel: perLevel,
|
||||
snapshotId: treeId,
|
||||
prevHeads: []string{treeId},
|
||||
isSnapshot: isSnapshot,
|
||||
hasData: hasData,
|
||||
}
|
||||
deps := fixtureDeps{
|
||||
aclList: aclList,
|
||||
initStorage: storage.(*treestorage.InMemoryTreeStorage),
|
||||
connectionMap: map[string][]string{
|
||||
"peer1": []string{"peer2"},
|
||||
"peer2": []string{"peer1"},
|
||||
},
|
||||
treeBuilder: builder,
|
||||
}
|
||||
fx := newProtocolFixture(t, spaceId, deps)
|
||||
|
||||
// generating parts
|
||||
firstPart := genChanges(changeCreator, params)
|
||||
params.startIdx = levels
|
||||
params.snapshotId = firstPart.snapshotId
|
||||
params.prevHeads = firstPart.heads
|
||||
secondPart := genChanges(changeCreator, params)
|
||||
params.startIdx = levels * 2
|
||||
params.snapshotId = secondPart.snapshotId
|
||||
params.prevHeads = secondPart.heads
|
||||
thirdPart := genChanges(changeCreator, params)
|
||||
|
||||
// adding part1 to first peer and saving part2 and part3 in its storage
|
||||
res, _ := fx.handlers["peer1"].tree().AddRawChanges(context.Background(), objecttree.RawChangesPayload{
|
||||
NewHeads: firstPart.heads,
|
||||
RawChanges: firstPart.changes,
|
||||
})
|
||||
require.True(t, slice.UnsortedEquals(res.Heads, firstPart.heads))
|
||||
store := fx.handlers["peer1"].tree().Storage().(*treestorage.InMemoryTreeStorage)
|
||||
oldHeads, _ := store.Heads()
|
||||
store.AddRawChangesSetHeads(secondPart.changes, oldHeads)
|
||||
store.AddRawChangesSetHeads(thirdPart.changes, oldHeads)
|
||||
|
||||
var peer2Initial []*treechangeproto.RawTreeChangeWithId
|
||||
peer2Initial = append(peer2Initial, firstPart.changes...)
|
||||
peer2Initial = append(peer2Initial, secondPart.changes...)
|
||||
|
||||
// adding part1 and part2 to second peer
|
||||
res, _ = fx.handlers["peer2"].tree().AddRawChanges(context.Background(), objecttree.RawChangesPayload{
|
||||
NewHeads: secondPart.heads,
|
||||
RawChanges: peer2Initial,
|
||||
})
|
||||
require.True(t, slice.UnsortedEquals(res.Heads, secondPart.heads))
|
||||
fx.run(t)
|
||||
|
||||
// sending part3 changes to other peer
|
||||
fx.handlers["peer2"].sendRawChanges(context.Background(), objecttree.RawChangesPayload{
|
||||
NewHeads: thirdPart.heads,
|
||||
RawChanges: thirdPart.changes,
|
||||
})
|
||||
time.Sleep(50 * time.Millisecond)
|
||||
firstHeads := fx.handlers["peer1"].tree().Heads()
|
||||
secondHeads := fx.handlers["peer2"].tree().Heads()
|
||||
require.True(t, slice.UnsortedEquals(firstHeads, secondHeads))
|
||||
require.True(t, slice.UnsortedEquals(thirdPart.heads, firstHeads))
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
//go:generate mockgen -destination mock_synctree/mock_synctree.go github.com/anyproto/any-sync/commonspace/object/tree/synctree SyncTree,ReceiveQueue,HeadNotifiable
|
||||
//go:generate mockgen -destination mock_synctree/mock_synctree.go github.com/anytypeio/any-sync/commonspace/object/tree/synctree SyncTree,ReceiveQueue,HeadNotifiable
|
||||
package synctree
|
||||
|
||||
import (
|
||||
@@ -6,17 +6,17 @@ import (
|
||||
"errors"
|
||||
"time"
|
||||
|
||||
"github.com/anyproto/any-sync/app/logger"
|
||||
"github.com/anyproto/any-sync/commonspace/object/acl/list"
|
||||
"github.com/anyproto/any-sync/commonspace/object/tree/objecttree"
|
||||
"github.com/anyproto/any-sync/commonspace/object/tree/synctree/updatelistener"
|
||||
"github.com/anyproto/any-sync/commonspace/object/tree/treestorage"
|
||||
"github.com/anyproto/any-sync/commonspace/objectsync"
|
||||
"github.com/anyproto/any-sync/commonspace/objectsync/synchandler"
|
||||
"github.com/anyproto/any-sync/commonspace/spacestorage"
|
||||
"github.com/anyproto/any-sync/commonspace/syncstatus"
|
||||
"github.com/anyproto/any-sync/net/peer"
|
||||
"github.com/anyproto/any-sync/nodeconf"
|
||||
"github.com/anytypeio/any-sync/app/logger"
|
||||
"github.com/anytypeio/any-sync/commonspace/object/acl/list"
|
||||
"github.com/anytypeio/any-sync/commonspace/object/tree/objecttree"
|
||||
"github.com/anytypeio/any-sync/commonspace/object/tree/synctree/updatelistener"
|
||||
"github.com/anytypeio/any-sync/commonspace/object/tree/treestorage"
|
||||
"github.com/anytypeio/any-sync/commonspace/objectsync"
|
||||
"github.com/anytypeio/any-sync/commonspace/objectsync/synchandler"
|
||||
"github.com/anytypeio/any-sync/commonspace/spacestorage"
|
||||
"github.com/anytypeio/any-sync/commonspace/syncstatus"
|
||||
"github.com/anytypeio/any-sync/net/peer"
|
||||
"github.com/anytypeio/any-sync/nodeconf"
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
@@ -76,15 +76,12 @@ type BuildDeps struct {
|
||||
}
|
||||
|
||||
func BuildSyncTreeOrGetRemote(ctx context.Context, id string, deps BuildDeps) (t SyncTree, err error) {
|
||||
var (
|
||||
remoteGetter = treeRemoteGetter{treeId: id, deps: deps}
|
||||
isRemote bool
|
||||
)
|
||||
deps.TreeStorage, isRemote, err = remoteGetter.getTree(ctx)
|
||||
remoteGetter := treeRemoteGetter{treeId: id, deps: deps}
|
||||
deps.TreeStorage, err = remoteGetter.getTree(ctx)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
return buildSyncTree(ctx, isRemote, deps)
|
||||
return buildSyncTree(ctx, true, deps)
|
||||
}
|
||||
|
||||
func PutSyncTree(ctx context.Context, payload treestorage.TreeStorageCreatePayload, deps BuildDeps) (t SyncTree, err error) {
|
||||
@@ -95,7 +92,7 @@ func PutSyncTree(ctx context.Context, payload treestorage.TreeStorageCreatePaylo
|
||||
return buildSyncTree(ctx, true, deps)
|
||||
}
|
||||
|
||||
func buildSyncTree(ctx context.Context, sendUpdate bool, deps BuildDeps) (t SyncTree, err error) {
|
||||
func buildSyncTree(ctx context.Context, isFirstBuild bool, deps BuildDeps) (t SyncTree, err error) {
|
||||
objTree, err := deps.BuildObjectTree(deps.TreeStorage, deps.AclList)
|
||||
if err != nil {
|
||||
return
|
||||
@@ -116,7 +113,7 @@ func buildSyncTree(ctx context.Context, sendUpdate bool, deps BuildDeps) (t Sync
|
||||
syncTree.afterBuild()
|
||||
syncTree.Unlock()
|
||||
|
||||
if sendUpdate {
|
||||
if isFirstBuild {
|
||||
headUpdate := syncTree.syncClient.CreateHeadUpdate(t, nil)
|
||||
// send to everybody, because everybody should know that the node or client got new tree
|
||||
syncTree.syncClient.Broadcast(ctx, headUpdate)
|
||||
|
||||
@@ -2,15 +2,15 @@ package synctree
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/anyproto/any-sync/commonspace/object/tree/objecttree"
|
||||
"github.com/anyproto/any-sync/commonspace/object/tree/objecttree/mock_objecttree"
|
||||
"github.com/anyproto/any-sync/commonspace/object/tree/synctree/updatelistener"
|
||||
"github.com/anyproto/any-sync/commonspace/object/tree/synctree/updatelistener/mock_updatelistener"
|
||||
"github.com/anyproto/any-sync/commonspace/object/tree/treechangeproto"
|
||||
"github.com/anyproto/any-sync/commonspace/objectsync"
|
||||
"github.com/anyproto/any-sync/commonspace/objectsync/mock_objectsync"
|
||||
"github.com/anyproto/any-sync/commonspace/syncstatus"
|
||||
"github.com/anyproto/any-sync/nodeconf"
|
||||
"github.com/anytypeio/any-sync/commonspace/object/tree/objecttree"
|
||||
"github.com/anytypeio/any-sync/commonspace/object/tree/objecttree/mock_objecttree"
|
||||
"github.com/anytypeio/any-sync/commonspace/object/tree/synctree/updatelistener"
|
||||
"github.com/anytypeio/any-sync/commonspace/object/tree/synctree/updatelistener/mock_updatelistener"
|
||||
"github.com/anytypeio/any-sync/commonspace/object/tree/treechangeproto"
|
||||
"github.com/anytypeio/any-sync/commonspace/objectsync"
|
||||
"github.com/anytypeio/any-sync/commonspace/objectsync/mock_objectsync"
|
||||
"github.com/anytypeio/any-sync/commonspace/syncstatus"
|
||||
"github.com/anytypeio/any-sync/nodeconf"
|
||||
"github.com/golang/mock/gomock"
|
||||
"github.com/stretchr/testify/require"
|
||||
"testing"
|
||||
|
||||
@@ -2,13 +2,13 @@ package synctree
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/anyproto/any-sync/commonspace/object/tree/objecttree"
|
||||
"github.com/anyproto/any-sync/commonspace/object/tree/treechangeproto"
|
||||
"github.com/anyproto/any-sync/commonspace/objectsync"
|
||||
"github.com/anyproto/any-sync/commonspace/objectsync/synchandler"
|
||||
"github.com/anyproto/any-sync/commonspace/spacesyncproto"
|
||||
"github.com/anyproto/any-sync/commonspace/syncstatus"
|
||||
"github.com/anyproto/any-sync/util/slice"
|
||||
"github.com/anytypeio/any-sync/commonspace/object/tree/objecttree"
|
||||
"github.com/anytypeio/any-sync/commonspace/object/tree/treechangeproto"
|
||||
"github.com/anytypeio/any-sync/commonspace/objectsync"
|
||||
"github.com/anytypeio/any-sync/commonspace/objectsync/synchandler"
|
||||
"github.com/anytypeio/any-sync/commonspace/spacesyncproto"
|
||||
"github.com/anytypeio/any-sync/commonspace/syncstatus"
|
||||
"github.com/anytypeio/any-sync/util/slice"
|
||||
"github.com/gogo/protobuf/proto"
|
||||
"go.uber.org/zap"
|
||||
"sync"
|
||||
@@ -93,7 +93,7 @@ func (s *syncTreeHandler) handleHeadUpdate(
|
||||
|
||||
defer func() {
|
||||
if err != nil {
|
||||
log.ErrorCtx(ctx, "head update finished with error", zap.Error(err))
|
||||
log.With(zap.Error(err)).Debug("head update finished with error")
|
||||
} else if fullRequest != nil {
|
||||
cnt := fullRequest.Content.GetFullSyncRequest()
|
||||
log = log.With(zap.Strings("request heads", cnt.Heads), zap.Int("len(request changes)", len(cnt.Changes)))
|
||||
@@ -168,7 +168,7 @@ func (s *syncTreeHandler) handleFullSyncRequest(
|
||||
|
||||
defer func() {
|
||||
if err != nil {
|
||||
log.ErrorCtx(ctx, "full sync request finished with error", zap.Error(err))
|
||||
log.With(zap.Error(err)).DebugCtx(ctx, "full sync request finished with error")
|
||||
s.syncClient.SendWithReply(ctx, senderId, treeId, treechangeproto.WrapError(treechangeproto.ErrFullSync, header), replyId)
|
||||
return
|
||||
} else if fullResponse != nil {
|
||||
@@ -212,7 +212,7 @@ func (s *syncTreeHandler) handleFullSyncResponse(
|
||||
|
||||
defer func() {
|
||||
if err != nil {
|
||||
log.ErrorCtx(ctx, "full sync response failed", zap.Error(err))
|
||||
log.With(zap.Error(err)).DebugCtx(ctx, "full sync response failed")
|
||||
} else {
|
||||
log.DebugCtx(ctx, "full sync response succeeded")
|
||||
}
|
||||
|
||||
@@ -3,16 +3,16 @@ package synctree
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"github.com/anyproto/any-sync/commonspace/objectsync"
|
||||
"github.com/anyproto/any-sync/commonspace/objectsync/mock_objectsync"
|
||||
"github.com/anytypeio/any-sync/commonspace/objectsync"
|
||||
"github.com/anytypeio/any-sync/commonspace/objectsync/mock_objectsync"
|
||||
"sync"
|
||||
"testing"
|
||||
|
||||
"github.com/anyproto/any-sync/app/logger"
|
||||
"github.com/anyproto/any-sync/commonspace/object/tree/objecttree"
|
||||
"github.com/anyproto/any-sync/commonspace/object/tree/objecttree/mock_objecttree"
|
||||
"github.com/anyproto/any-sync/commonspace/object/tree/treechangeproto"
|
||||
"github.com/anyproto/any-sync/commonspace/syncstatus"
|
||||
"github.com/anytypeio/any-sync/app/logger"
|
||||
"github.com/anytypeio/any-sync/commonspace/object/tree/objecttree"
|
||||
"github.com/anytypeio/any-sync/commonspace/object/tree/objecttree/mock_objecttree"
|
||||
"github.com/anytypeio/any-sync/commonspace/object/tree/treechangeproto"
|
||||
"github.com/anytypeio/any-sync/commonspace/syncstatus"
|
||||
"github.com/golang/mock/gomock"
|
||||
"github.com/stretchr/testify/require"
|
||||
"go.uber.org/zap"
|
||||
|
||||
@@ -3,12 +3,12 @@ package synctree
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"github.com/anyproto/any-sync/commonspace/object/tree/objecttree"
|
||||
"github.com/anyproto/any-sync/commonspace/object/tree/treechangeproto"
|
||||
"github.com/anyproto/any-sync/commonspace/object/tree/treestorage"
|
||||
"github.com/anyproto/any-sync/commonspace/spacestorage"
|
||||
"github.com/anyproto/any-sync/net/peer"
|
||||
"github.com/anyproto/any-sync/net/rpc/rpcerr"
|
||||
"github.com/anytypeio/any-sync/commonspace/object/tree/objecttree"
|
||||
"github.com/anytypeio/any-sync/commonspace/object/tree/treechangeproto"
|
||||
"github.com/anytypeio/any-sync/commonspace/object/tree/treestorage"
|
||||
"github.com/anytypeio/any-sync/commonspace/spacestorage"
|
||||
"github.com/anytypeio/any-sync/net/peer"
|
||||
"github.com/anytypeio/any-sync/net/rpc/rpcerr"
|
||||
"github.com/gogo/protobuf/proto"
|
||||
"go.uber.org/zap"
|
||||
"time"
|
||||
@@ -90,11 +90,12 @@ Loop:
|
||||
}
|
||||
}
|
||||
|
||||
func (t treeRemoteGetter) getTree(ctx context.Context) (treeStorage treestorage.TreeStorage, isRemote bool, err error) {
|
||||
func (t treeRemoteGetter) getTree(ctx context.Context) (treeStorage treestorage.TreeStorage, err error) {
|
||||
treeStorage, err = t.deps.SpaceStorage.TreeStorage(t.treeId)
|
||||
if err == nil {
|
||||
return
|
||||
}
|
||||
|
||||
if err != nil && err != treestorage.ErrUnknownTreeId {
|
||||
return
|
||||
}
|
||||
@@ -108,7 +109,6 @@ func (t treeRemoteGetter) getTree(ctx context.Context) (treeStorage treestorage.
|
||||
return
|
||||
}
|
||||
|
||||
isRemote = true
|
||||
resp, err := t.treeRequestLoop(ctx, t.deps.WaitTreeRemoteSync)
|
||||
if err != nil {
|
||||
return
|
||||
@@ -139,6 +139,5 @@ func (t treeRemoteGetter) getTree(ctx context.Context) (treeStorage treestorage.
|
||||
return
|
||||
}
|
||||
// now we are sure that we can save it to the storage
|
||||
treeStorage, err = t.deps.SpaceStorage.CreateTreeStorage(payload)
|
||||
return
|
||||
return t.deps.SpaceStorage.CreateTreeStorage(payload)
|
||||
}
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
// Code generated by MockGen. DO NOT EDIT.
|
||||
// Source: github.com/anyproto/any-sync/commonspace/object/tree/synctree/updatelistener (interfaces: UpdateListener)
|
||||
// Source: github.com/anytypeio/any-sync/commonspace/object/tree/synctree/updatelistener (interfaces: UpdateListener)
|
||||
|
||||
// Package mock_updatelistener is a generated GoMock package.
|
||||
package mock_updatelistener
|
||||
@@ -7,7 +7,7 @@ package mock_updatelistener
|
||||
import (
|
||||
reflect "reflect"
|
||||
|
||||
objecttree "github.com/anyproto/any-sync/commonspace/object/tree/objecttree"
|
||||
objecttree "github.com/anytypeio/any-sync/commonspace/object/tree/objecttree"
|
||||
gomock "github.com/golang/mock/gomock"
|
||||
)
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
//go:generate mockgen -destination mock_updatelistener/mock_updatelistener.go github.com/anyproto/any-sync/commonspace/object/tree/synctree/updatelistener UpdateListener
|
||||
//go:generate mockgen -destination mock_updatelistener/mock_updatelistener.go github.com/anytypeio/any-sync/commonspace/object/tree/synctree/updatelistener UpdateListener
|
||||
package updatelistener
|
||||
|
||||
import (
|
||||
"github.com/anyproto/any-sync/commonspace/object/tree/objecttree"
|
||||
"github.com/anytypeio/any-sync/commonspace/object/tree/objecttree"
|
||||
)
|
||||
|
||||
type UpdateListener interface {
|
||||
|
||||
@@ -3,15 +3,15 @@ package synctree
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"github.com/anyproto/any-sync/commonspace/object/acl/list"
|
||||
"github.com/anyproto/any-sync/commonspace/object/tree/objecttree"
|
||||
"github.com/anyproto/any-sync/commonspace/object/tree/treechangeproto"
|
||||
"github.com/anyproto/any-sync/commonspace/object/tree/treestorage"
|
||||
"github.com/anyproto/any-sync/commonspace/objectsync"
|
||||
"github.com/anyproto/any-sync/commonspace/objectsync/synchandler"
|
||||
"github.com/anyproto/any-sync/commonspace/spacesyncproto"
|
||||
"github.com/anyproto/any-sync/commonspace/syncstatus"
|
||||
"github.com/anyproto/any-sync/net/peer"
|
||||
"github.com/anytypeio/any-sync/commonspace/object/acl/list"
|
||||
"github.com/anytypeio/any-sync/commonspace/object/tree/objecttree"
|
||||
"github.com/anytypeio/any-sync/commonspace/object/tree/treechangeproto"
|
||||
"github.com/anytypeio/any-sync/commonspace/object/tree/treestorage"
|
||||
"github.com/anytypeio/any-sync/commonspace/objectsync"
|
||||
"github.com/anytypeio/any-sync/commonspace/objectsync/synchandler"
|
||||
"github.com/anytypeio/any-sync/commonspace/spacesyncproto"
|
||||
"github.com/anytypeio/any-sync/commonspace/syncstatus"
|
||||
"github.com/anytypeio/any-sync/net/peer"
|
||||
"github.com/cheggaaa/mb/v3"
|
||||
"github.com/gogo/protobuf/proto"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
@@ -2,7 +2,7 @@ package treechangeproto
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"github.com/anyproto/any-sync/net/rpc/rpcerr"
|
||||
"github.com/anytypeio/any-sync/net/rpc/rpcerr"
|
||||
)
|
||||
|
||||
var (
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package treechangeproto
|
||||
|
||||
import "github.com/anyproto/any-sync/net/rpc/rpcerr"
|
||||
import "github.com/anytypeio/any-sync/net/rpc/rpcerr"
|
||||
|
||||
func WrapHeadUpdate(update *TreeHeadUpdate, rootChange *RawTreeChangeWithId) *TreeSyncMessage {
|
||||
return &TreeSyncMessage{
|
||||
|
||||
@@ -3,8 +3,8 @@ package treestorage
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"github.com/anyproto/any-sync/commonspace/object/tree/treechangeproto"
|
||||
"github.com/anyproto/any-sync/util/slice"
|
||||
"github.com/anytypeio/any-sync/commonspace/object/tree/treechangeproto"
|
||||
"github.com/anytypeio/any-sync/util/slice"
|
||||
"sync"
|
||||
)
|
||||
|
||||
@@ -13,21 +13,13 @@ type InMemoryTreeStorage struct {
|
||||
root *treechangeproto.RawTreeChangeWithId
|
||||
heads []string
|
||||
Changes map[string]*treechangeproto.RawTreeChangeWithId
|
||||
addErr error
|
||||
|
||||
sync.RWMutex
|
||||
}
|
||||
|
||||
func (t *InMemoryTreeStorage) SetReturnErrorOnAdd(err error) {
|
||||
t.addErr = err
|
||||
}
|
||||
|
||||
func (t *InMemoryTreeStorage) AddRawChangesSetHeads(changes []*treechangeproto.RawTreeChangeWithId, heads []string) error {
|
||||
func (t *InMemoryTreeStorage) TransactionAdd(changes []*treechangeproto.RawTreeChangeWithId, heads []string) error {
|
||||
t.RLock()
|
||||
defer t.RUnlock()
|
||||
if t.addErr != nil {
|
||||
return t.addErr
|
||||
}
|
||||
|
||||
for _, ch := range changes {
|
||||
t.Changes[ch.Id] = ch
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// Code generated by MockGen. DO NOT EDIT.
|
||||
// Source: github.com/anyproto/any-sync/commonspace/object/tree/treestorage (interfaces: TreeStorage)
|
||||
// Source: github.com/anytypeio/any-sync/commonspace/object/tree/treestorage (interfaces: TreeStorage)
|
||||
|
||||
// Package mock_treestorage is a generated GoMock package.
|
||||
package mock_treestorage
|
||||
@@ -8,7 +8,7 @@ import (
|
||||
context "context"
|
||||
reflect "reflect"
|
||||
|
||||
treechangeproto "github.com/anyproto/any-sync/commonspace/object/tree/treechangeproto"
|
||||
treechangeproto "github.com/anytypeio/any-sync/commonspace/object/tree/treechangeproto"
|
||||
gomock "github.com/golang/mock/gomock"
|
||||
)
|
||||
|
||||
@@ -49,20 +49,6 @@ func (mr *MockTreeStorageMockRecorder) AddRawChange(arg0 interface{}) *gomock.Ca
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AddRawChange", reflect.TypeOf((*MockTreeStorage)(nil).AddRawChange), arg0)
|
||||
}
|
||||
|
||||
// AddRawChangesSetHeads mocks base method.
|
||||
func (m *MockTreeStorage) AddRawChangesSetHeads(arg0 []*treechangeproto.RawTreeChangeWithId, arg1 []string) error {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "AddRawChangesSetHeads", arg0, arg1)
|
||||
ret0, _ := ret[0].(error)
|
||||
return ret0
|
||||
}
|
||||
|
||||
// AddRawChangesSetHeads indicates an expected call of AddRawChangesSetHeads.
|
||||
func (mr *MockTreeStorageMockRecorder) AddRawChangesSetHeads(arg0, arg1 interface{}) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AddRawChangesSetHeads", reflect.TypeOf((*MockTreeStorage)(nil).AddRawChangesSetHeads), arg0, arg1)
|
||||
}
|
||||
|
||||
// Delete mocks base method.
|
||||
func (m *MockTreeStorage) Delete() error {
|
||||
m.ctrl.T.Helper()
|
||||
@@ -164,3 +150,17 @@ func (mr *MockTreeStorageMockRecorder) SetHeads(arg0 interface{}) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetHeads", reflect.TypeOf((*MockTreeStorage)(nil).SetHeads), arg0)
|
||||
}
|
||||
|
||||
// TransactionAdd mocks base method.
|
||||
func (m *MockTreeStorage) TransactionAdd(arg0 []*treechangeproto.RawTreeChangeWithId, arg1 []string) error {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "TransactionAdd", arg0, arg1)
|
||||
ret0, _ := ret[0].(error)
|
||||
return ret0
|
||||
}
|
||||
|
||||
// TransactionAdd indicates an expected call of TransactionAdd.
|
||||
func (mr *MockTreeStorageMockRecorder) TransactionAdd(arg0, arg1 interface{}) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "TransactionAdd", reflect.TypeOf((*MockTreeStorage)(nil).TransactionAdd), arg0, arg1)
|
||||
}
|
||||
@@ -1,10 +1,10 @@
|
||||
//go:generate mockgen -destination mock_treestorage/mock_treestorage.go github.com/anyproto/any-sync/commonspace/object/tree/treestorage TreeStorage
|
||||
//go:generate mockgen -destination mock_treestorage/mock_treestorage.go github.com/anytypeio/any-sync/commonspace/object/tree/treestorage TreeStorage
|
||||
package treestorage
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"github.com/anyproto/any-sync/commonspace/object/tree/treechangeproto"
|
||||
"github.com/anytypeio/any-sync/commonspace/object/tree/treechangeproto"
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -31,7 +31,7 @@ type TreeStorage interface {
|
||||
Heads() ([]string, error)
|
||||
SetHeads(heads []string) error
|
||||
AddRawChange(change *treechangeproto.RawTreeChangeWithId) error
|
||||
AddRawChangesSetHeads(changes []*treechangeproto.RawTreeChangeWithId, heads []string) error
|
||||
TransactionAdd(changes []*treechangeproto.RawTreeChangeWithId, heads []string) error
|
||||
|
||||
GetRawChange(ctx context.Context, id string) (*treechangeproto.RawTreeChangeWithId, error)
|
||||
HasChange(ctx context.Context, id string) (bool, error)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// Code generated by MockGen. DO NOT EDIT.
|
||||
// Source: github.com/anyproto/any-sync/commonspace/object/treemanager (interfaces: TreeManager,TreeSyncer)
|
||||
// Source: github.com/anytypeio/any-sync/commonspace/object/treemanager (interfaces: TreeManager)
|
||||
|
||||
// Package mock_treemanager is a generated GoMock package.
|
||||
package mock_treemanager
|
||||
@@ -8,9 +8,8 @@ import (
|
||||
context "context"
|
||||
reflect "reflect"
|
||||
|
||||
app "github.com/anyproto/any-sync/app"
|
||||
objecttree "github.com/anyproto/any-sync/commonspace/object/tree/objecttree"
|
||||
treemanager "github.com/anyproto/any-sync/commonspace/object/treemanager"
|
||||
app "github.com/anytypeio/any-sync/app"
|
||||
objecttree "github.com/anytypeio/any-sync/commonspace/object/tree/objecttree"
|
||||
gomock "github.com/golang/mock/gomock"
|
||||
)
|
||||
|
||||
@@ -94,20 +93,6 @@ func (mr *MockTreeManagerMockRecorder) Init(arg0 interface{}) *gomock.Call {
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Init", reflect.TypeOf((*MockTreeManager)(nil).Init), arg0)
|
||||
}
|
||||
|
||||
// MarkTreeDeleted mocks base method.
|
||||
func (m *MockTreeManager) MarkTreeDeleted(arg0 context.Context, arg1, arg2 string) error {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "MarkTreeDeleted", arg0, arg1, arg2)
|
||||
ret0, _ := ret[0].(error)
|
||||
return ret0
|
||||
}
|
||||
|
||||
// MarkTreeDeleted indicates an expected call of MarkTreeDeleted.
|
||||
func (mr *MockTreeManagerMockRecorder) MarkTreeDeleted(arg0, arg1, arg2 interface{}) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "MarkTreeDeleted", reflect.TypeOf((*MockTreeManager)(nil).MarkTreeDeleted), arg0, arg1, arg2)
|
||||
}
|
||||
|
||||
// Name mocks base method.
|
||||
func (m *MockTreeManager) Name() string {
|
||||
m.ctrl.T.Helper()
|
||||
@@ -122,20 +107,6 @@ func (mr *MockTreeManagerMockRecorder) Name() *gomock.Call {
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Name", reflect.TypeOf((*MockTreeManager)(nil).Name))
|
||||
}
|
||||
|
||||
// NewTreeSyncer mocks base method.
|
||||
func (m *MockTreeManager) NewTreeSyncer(arg0 string, arg1 treemanager.TreeManager) treemanager.TreeSyncer {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "NewTreeSyncer", arg0, arg1)
|
||||
ret0, _ := ret[0].(treemanager.TreeSyncer)
|
||||
return ret0
|
||||
}
|
||||
|
||||
// NewTreeSyncer indicates an expected call of NewTreeSyncer.
|
||||
func (mr *MockTreeManagerMockRecorder) NewTreeSyncer(arg0, arg1 interface{}) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "NewTreeSyncer", reflect.TypeOf((*MockTreeManager)(nil).NewTreeSyncer), arg0, arg1)
|
||||
}
|
||||
|
||||
// Run mocks base method.
|
||||
func (m *MockTreeManager) Run(arg0 context.Context) error {
|
||||
m.ctrl.T.Helper()
|
||||
@@ -149,66 +120,3 @@ func (mr *MockTreeManagerMockRecorder) Run(arg0 interface{}) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Run", reflect.TypeOf((*MockTreeManager)(nil).Run), arg0)
|
||||
}
|
||||
|
||||
// MockTreeSyncer is a mock of TreeSyncer interface.
|
||||
type MockTreeSyncer struct {
|
||||
ctrl *gomock.Controller
|
||||
recorder *MockTreeSyncerMockRecorder
|
||||
}
|
||||
|
||||
// MockTreeSyncerMockRecorder is the mock recorder for MockTreeSyncer.
|
||||
type MockTreeSyncerMockRecorder struct {
|
||||
mock *MockTreeSyncer
|
||||
}
|
||||
|
||||
// NewMockTreeSyncer creates a new mock instance.
|
||||
func NewMockTreeSyncer(ctrl *gomock.Controller) *MockTreeSyncer {
|
||||
mock := &MockTreeSyncer{ctrl: ctrl}
|
||||
mock.recorder = &MockTreeSyncerMockRecorder{mock}
|
||||
return mock
|
||||
}
|
||||
|
||||
// EXPECT returns an object that allows the caller to indicate expected use.
|
||||
func (m *MockTreeSyncer) EXPECT() *MockTreeSyncerMockRecorder {
|
||||
return m.recorder
|
||||
}
|
||||
|
||||
// Close mocks base method.
|
||||
func (m *MockTreeSyncer) Close() error {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "Close")
|
||||
ret0, _ := ret[0].(error)
|
||||
return ret0
|
||||
}
|
||||
|
||||
// Close indicates an expected call of Close.
|
||||
func (mr *MockTreeSyncerMockRecorder) Close() *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Close", reflect.TypeOf((*MockTreeSyncer)(nil).Close))
|
||||
}
|
||||
|
||||
// Init mocks base method.
|
||||
func (m *MockTreeSyncer) Init() {
|
||||
m.ctrl.T.Helper()
|
||||
m.ctrl.Call(m, "Init")
|
||||
}
|
||||
|
||||
// Init indicates an expected call of Init.
|
||||
func (mr *MockTreeSyncerMockRecorder) Init() *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Init", reflect.TypeOf((*MockTreeSyncer)(nil).Init))
|
||||
}
|
||||
|
||||
// SyncAll mocks base method.
|
||||
func (m *MockTreeSyncer) SyncAll(arg0 context.Context, arg1 string, arg2, arg3 []string) error {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "SyncAll", arg0, arg1, arg2, arg3)
|
||||
ret0, _ := ret[0].(error)
|
||||
return ret0
|
||||
}
|
||||
|
||||
// SyncAll indicates an expected call of SyncAll.
|
||||
func (mr *MockTreeSyncerMockRecorder) SyncAll(arg0, arg1, arg2, arg3 interface{}) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SyncAll", reflect.TypeOf((*MockTreeSyncer)(nil).SyncAll), arg0, arg1, arg2, arg3)
|
||||
}
|
||||
@@ -1,10 +1,10 @@
|
||||
//go:generate mockgen -destination mock_treemanager/mock_treemanager.go github.com/anyproto/any-sync/commonspace/object/treemanager TreeManager,TreeSyncer
|
||||
//go:generate mockgen -destination mock_treemanager/mock_treemanager.go github.com/anytypeio/any-sync/commonspace/object/treemanager TreeManager
|
||||
package treemanager
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/anyproto/any-sync/app"
|
||||
"github.com/anyproto/any-sync/commonspace/object/tree/objecttree"
|
||||
"github.com/anytypeio/any-sync/app"
|
||||
"github.com/anytypeio/any-sync/commonspace/object/tree/objecttree"
|
||||
)
|
||||
|
||||
const CName = "common.object.treemanager"
|
||||
@@ -12,13 +12,5 @@ const CName = "common.object.treemanager"
|
||||
type TreeManager interface {
|
||||
app.ComponentRunnable
|
||||
GetTree(ctx context.Context, spaceId, treeId string) (objecttree.ObjectTree, error)
|
||||
MarkTreeDeleted(ctx context.Context, spaceId, treeId string) error
|
||||
DeleteTree(ctx context.Context, spaceId, treeId string) error
|
||||
NewTreeSyncer(spaceId string, treeManager TreeManager) TreeSyncer
|
||||
}
|
||||
|
||||
type TreeSyncer interface {
|
||||
Init()
|
||||
SyncAll(ctx context.Context, peerId string, existing, missing []string) error
|
||||
Close() error
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
// Code generated by MockGen. DO NOT EDIT.
|
||||
// Source: github.com/anyproto/any-sync/commonspace/objectsync (interfaces: SyncClient)
|
||||
// Source: github.com/anytypeio/any-sync/commonspace/objectsync (interfaces: SyncClient)
|
||||
|
||||
// Package mock_objectsync is a generated GoMock package.
|
||||
package mock_objectsync
|
||||
@@ -8,10 +8,10 @@ import (
|
||||
context "context"
|
||||
reflect "reflect"
|
||||
|
||||
objecttree "github.com/anyproto/any-sync/commonspace/object/tree/objecttree"
|
||||
treechangeproto "github.com/anyproto/any-sync/commonspace/object/tree/treechangeproto"
|
||||
objectsync "github.com/anyproto/any-sync/commonspace/objectsync"
|
||||
spacesyncproto "github.com/anyproto/any-sync/commonspace/spacesyncproto"
|
||||
objecttree "github.com/anytypeio/any-sync/commonspace/object/tree/objecttree"
|
||||
treechangeproto "github.com/anytypeio/any-sync/commonspace/object/tree/treechangeproto"
|
||||
objectsync "github.com/anytypeio/any-sync/commonspace/objectsync"
|
||||
spacesyncproto "github.com/anytypeio/any-sync/commonspace/spacesyncproto"
|
||||
gomock "github.com/golang/mock/gomock"
|
||||
)
|
||||
|
||||
|
||||
@@ -3,9 +3,9 @@ package objectsync
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"github.com/anyproto/any-sync/commonspace/objectsync/synchandler"
|
||||
"github.com/anyproto/any-sync/commonspace/peermanager"
|
||||
"github.com/anyproto/any-sync/commonspace/spacesyncproto"
|
||||
"github.com/anytypeio/any-sync/commonspace/objectsync/synchandler"
|
||||
"github.com/anytypeio/any-sync/commonspace/peermanager"
|
||||
"github.com/anytypeio/any-sync/commonspace/spacesyncproto"
|
||||
"go.uber.org/zap"
|
||||
"strconv"
|
||||
"strings"
|
||||
@@ -53,11 +53,9 @@ func newMessagePool(peerManager peermanager.PeerManager, messageHandler MessageH
|
||||
|
||||
func (s *messagePool) SendSync(ctx context.Context, peerId string, msg *spacesyncproto.ObjectSyncMessage) (reply *spacesyncproto.ObjectSyncMessage, err error) {
|
||||
s.updateLastUsage()
|
||||
if _, ok := ctx.Deadline(); !ok {
|
||||
var cancel context.CancelFunc
|
||||
ctx, cancel = context.WithTimeout(ctx, time.Minute)
|
||||
defer cancel()
|
||||
}
|
||||
var cancel context.CancelFunc
|
||||
ctx, cancel = context.WithTimeout(ctx, time.Second*10)
|
||||
defer cancel()
|
||||
newCounter := s.counter.Add(1)
|
||||
msg.RequestId = genReplyKey(peerId, msg.ObjectId, newCounter)
|
||||
log.InfoCtx(ctx, "mpool sendSync", zap.String("requestId", msg.RequestId))
|
||||
@@ -105,7 +103,6 @@ func (s *messagePool) HandleMessage(ctx context.Context, senderId string, msg *s
|
||||
return
|
||||
}
|
||||
log.WarnCtx(ctx, "reply id does not exist", zap.String("replyId", msg.ReplyId))
|
||||
return
|
||||
}
|
||||
return s.messageHandler(ctx, senderId, msg)
|
||||
}
|
||||
|
||||
@@ -1,21 +1,20 @@
|
||||
//go:generate mockgen -destination mock_objectsync/mock_objectsync.go github.com/anyproto/any-sync/commonspace/objectsync SyncClient
|
||||
//go:generate mockgen -destination mock_objectsync/mock_objectsync.go github.com/anytypeio/any-sync/commonspace/objectsync SyncClient
|
||||
package objectsync
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"github.com/anyproto/any-sync/commonspace/object/tree/treechangeproto"
|
||||
"github.com/anytypeio/any-sync/commonspace/object/tree/treechangeproto"
|
||||
"github.com/gogo/protobuf/proto"
|
||||
"sync/atomic"
|
||||
"time"
|
||||
|
||||
"github.com/anyproto/any-sync/app/logger"
|
||||
"github.com/anyproto/any-sync/commonspace/object/syncobjectgetter"
|
||||
"github.com/anyproto/any-sync/commonspace/objectsync/synchandler"
|
||||
"github.com/anyproto/any-sync/commonspace/peermanager"
|
||||
"github.com/anyproto/any-sync/commonspace/spacestorage"
|
||||
"github.com/anyproto/any-sync/commonspace/spacesyncproto"
|
||||
"github.com/anyproto/any-sync/nodeconf"
|
||||
"github.com/anytypeio/any-sync/app/logger"
|
||||
"github.com/anytypeio/any-sync/commonspace/object/syncobjectgetter"
|
||||
"github.com/anytypeio/any-sync/commonspace/objectsync/synchandler"
|
||||
"github.com/anytypeio/any-sync/commonspace/peermanager"
|
||||
"github.com/anytypeio/any-sync/commonspace/spacestorage"
|
||||
"github.com/anytypeio/any-sync/commonspace/spacesyncproto"
|
||||
"github.com/anytypeio/any-sync/nodeconf"
|
||||
"go.uber.org/zap"
|
||||
"golang.org/x/exp/slices"
|
||||
)
|
||||
@@ -88,68 +87,50 @@ func (s *objectSync) handleMessage(ctx context.Context, senderId string, msg *sp
|
||||
log = log.With(zap.Bool("isDeleted", true))
|
||||
// preventing sync with other clients if they are not just syncing the settings tree
|
||||
if !slices.Contains(s.configuration.NodeIds(s.spaceId), senderId) && msg.ObjectId != s.spaceStorage.SpaceSettingsId() {
|
||||
s.unmarshallSendError(ctx, msg, spacesyncproto.ErrUnexpected, senderId, msg.ObjectId)
|
||||
return fmt.Errorf("can't perform operation with object, space is deleted")
|
||||
return s.unmarshallSendError(ctx, msg, spacesyncproto.ErrSpaceIsDeleted, senderId, msg.ObjectId)
|
||||
}
|
||||
}
|
||||
log.DebugCtx(ctx, "handling message")
|
||||
hasTree, err := s.spaceStorage.HasTree(msg.ObjectId)
|
||||
if err != nil {
|
||||
s.unmarshallSendError(ctx, msg, spacesyncproto.ErrUnexpected, senderId, msg.ObjectId)
|
||||
return fmt.Errorf("falied to execute get operation on storage has tree: %w", err)
|
||||
return s.unmarshallSendError(ctx, msg, spacesyncproto.ErrUnexpected, senderId, msg.ObjectId)
|
||||
}
|
||||
// in this case we will try to get it from remote, unless the sender also sent us the same request :-)
|
||||
if !hasTree {
|
||||
treeMsg := &treechangeproto.TreeSyncMessage{}
|
||||
err = proto.Unmarshal(msg.Payload, treeMsg)
|
||||
if err != nil {
|
||||
s.sendError(ctx, nil, spacesyncproto.ErrUnexpected, senderId, msg.ObjectId, msg.RequestId)
|
||||
return fmt.Errorf("failed to unmarshall tree sync message: %w", err)
|
||||
return s.sendError(ctx, nil, spacesyncproto.ErrUnexpected, senderId, msg.ObjectId, msg.RequestId)
|
||||
}
|
||||
// this means that we don't have the tree locally and therefore can't return it
|
||||
if s.isEmptyFullSyncRequest(treeMsg) {
|
||||
err = treechangeproto.ErrGetTree
|
||||
s.sendError(ctx, nil, treechangeproto.ErrGetTree, senderId, msg.ObjectId, msg.RequestId)
|
||||
return fmt.Errorf("failed to get tree from storage on full sync: %w", err)
|
||||
return s.sendError(ctx, nil, treechangeproto.ErrGetTree, senderId, msg.ObjectId, msg.RequestId)
|
||||
}
|
||||
}
|
||||
obj, err := s.objectGetter.GetObject(ctx, msg.ObjectId)
|
||||
if err != nil {
|
||||
// TODO: write tests for object sync https://linear.app/anytype/issue/GO-1299/write-tests-for-commonspaceobjectsync
|
||||
s.unmarshallSendError(ctx, msg, spacesyncproto.ErrUnexpected, senderId, msg.ObjectId)
|
||||
return fmt.Errorf("failed to get object from cache: %w", err)
|
||||
log.DebugCtx(ctx, "failed to get object")
|
||||
return s.unmarshallSendError(ctx, msg, err, msg.ObjectId, senderId)
|
||||
}
|
||||
// TODO: unmarshall earlier
|
||||
err = obj.HandleMessage(ctx, senderId, msg)
|
||||
if err != nil {
|
||||
s.unmarshallSendError(ctx, msg, spacesyncproto.ErrUnexpected, senderId, msg.ObjectId)
|
||||
return fmt.Errorf("failed to handle message: %w", err)
|
||||
}
|
||||
return
|
||||
return obj.HandleMessage(ctx, senderId, msg)
|
||||
}
|
||||
|
||||
func (s *objectSync) SyncClient() SyncClient {
|
||||
return s.syncClient
|
||||
}
|
||||
|
||||
func (s *objectSync) unmarshallSendError(ctx context.Context, msg *spacesyncproto.ObjectSyncMessage, respErr error, senderId, objectId string) {
|
||||
func (s *objectSync) unmarshallSendError(ctx context.Context, msg *spacesyncproto.ObjectSyncMessage, respErr error, senderId, objectId string) (err error) {
|
||||
unmarshalled := &treechangeproto.TreeSyncMessage{}
|
||||
err := proto.Unmarshal(msg.Payload, unmarshalled)
|
||||
err = proto.Unmarshal(msg.Payload, unmarshalled)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
s.sendError(ctx, unmarshalled.RootChange, respErr, senderId, objectId, msg.RequestId)
|
||||
return s.sendError(ctx, unmarshalled.RootChange, respErr, senderId, objectId, msg.RequestId)
|
||||
}
|
||||
|
||||
func (s *objectSync) sendError(ctx context.Context, root *treechangeproto.RawTreeChangeWithId, respErr error, senderId, objectId, replyId string) {
|
||||
// we don't send errors if have no reply id, this can lead to bugs and also nobody needs this error
|
||||
if replyId == "" {
|
||||
return
|
||||
}
|
||||
func (s *objectSync) sendError(ctx context.Context, root *treechangeproto.RawTreeChangeWithId, respErr error, senderId, objectId, replyId string) (err error) {
|
||||
resp := treechangeproto.WrapError(respErr, root)
|
||||
if err := s.syncClient.SendWithReply(ctx, senderId, objectId, resp, replyId); err != nil {
|
||||
log.InfoCtx(ctx, "failed to send error to client")
|
||||
}
|
||||
return s.syncClient.SendWithReply(ctx, senderId, objectId, resp, replyId)
|
||||
}
|
||||
|
||||
func (s *objectSync) isEmptyFullSyncRequest(msg *treechangeproto.TreeSyncMessage) bool {
|
||||
|
||||
@@ -2,9 +2,9 @@ package objectsync
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/anyproto/any-sync/commonspace/object/tree/objecttree"
|
||||
"github.com/anyproto/any-sync/commonspace/object/tree/treechangeproto"
|
||||
"github.com/anyproto/any-sync/util/slice"
|
||||
"github.com/anytypeio/any-sync/commonspace/object/tree/objecttree"
|
||||
"github.com/anytypeio/any-sync/commonspace/object/tree/treechangeproto"
|
||||
"github.com/anytypeio/any-sync/util/slice"
|
||||
)
|
||||
|
||||
type RequestFactory interface {
|
||||
|
||||
@@ -2,8 +2,8 @@ package objectsync
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/anyproto/any-sync/commonspace/object/tree/treechangeproto"
|
||||
"github.com/anyproto/any-sync/commonspace/spacesyncproto"
|
||||
"github.com/anytypeio/any-sync/commonspace/object/tree/treechangeproto"
|
||||
"github.com/anytypeio/any-sync/commonspace/spacesyncproto"
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ package synchandler
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/anyproto/any-sync/commonspace/spacesyncproto"
|
||||
"github.com/anytypeio/any-sync/commonspace/spacesyncproto"
|
||||
)
|
||||
|
||||
type SyncHandler interface {
|
||||
|
||||
@@ -2,14 +2,14 @@ package commonspace
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"github.com/anyproto/any-sync/commonspace/object/acl/aclrecordproto"
|
||||
"github.com/anyproto/any-sync/commonspace/object/acl/list"
|
||||
"github.com/anyproto/any-sync/commonspace/object/tree/objecttree"
|
||||
"github.com/anyproto/any-sync/commonspace/object/tree/treechangeproto"
|
||||
"github.com/anyproto/any-sync/commonspace/spacestorage"
|
||||
"github.com/anyproto/any-sync/commonspace/spacesyncproto"
|
||||
"github.com/anyproto/any-sync/util/cidutil"
|
||||
"github.com/anyproto/any-sync/util/crypto"
|
||||
"github.com/anytypeio/any-sync/commonspace/object/acl/aclrecordproto"
|
||||
"github.com/anytypeio/any-sync/commonspace/object/acl/list"
|
||||
"github.com/anytypeio/any-sync/commonspace/object/tree/objecttree"
|
||||
"github.com/anytypeio/any-sync/commonspace/object/tree/treechangeproto"
|
||||
"github.com/anytypeio/any-sync/commonspace/spacestorage"
|
||||
"github.com/anytypeio/any-sync/commonspace/spacesyncproto"
|
||||
"github.com/anytypeio/any-sync/util/cidutil"
|
||||
"github.com/anytypeio/any-sync/util/crypto"
|
||||
"github.com/gogo/protobuf/proto"
|
||||
"hash/fnv"
|
||||
"math/rand"
|
||||
|
||||
@@ -2,14 +2,14 @@ package commonspace
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/anyproto/any-sync/commonspace/object/accountdata"
|
||||
"github.com/anyproto/any-sync/commonspace/object/acl/aclrecordproto"
|
||||
"github.com/anyproto/any-sync/commonspace/object/tree/objecttree"
|
||||
"github.com/anyproto/any-sync/commonspace/object/tree/treechangeproto"
|
||||
"github.com/anyproto/any-sync/commonspace/spacestorage"
|
||||
"github.com/anyproto/any-sync/commonspace/spacesyncproto"
|
||||
"github.com/anyproto/any-sync/util/cidutil"
|
||||
"github.com/anyproto/any-sync/util/crypto"
|
||||
"github.com/anytypeio/any-sync/commonspace/object/accountdata"
|
||||
"github.com/anytypeio/any-sync/commonspace/object/acl/aclrecordproto"
|
||||
"github.com/anytypeio/any-sync/commonspace/object/tree/objecttree"
|
||||
"github.com/anytypeio/any-sync/commonspace/object/tree/treechangeproto"
|
||||
"github.com/anytypeio/any-sync/commonspace/spacestorage"
|
||||
"github.com/anytypeio/any-sync/commonspace/spacesyncproto"
|
||||
"github.com/anytypeio/any-sync/util/cidutil"
|
||||
"github.com/anytypeio/any-sync/util/crypto"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
"math/rand"
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// Code generated by MockGen. DO NOT EDIT.
|
||||
// Source: github.com/anyproto/any-sync/commonspace/peermanager (interfaces: PeerManager)
|
||||
// Source: github.com/anytypeio/any-sync/commonspace/peermanager (interfaces: PeerManager)
|
||||
|
||||
// Package mock_peermanager is a generated GoMock package.
|
||||
package mock_peermanager
|
||||
@@ -8,8 +8,8 @@ import (
|
||||
context "context"
|
||||
reflect "reflect"
|
||||
|
||||
spacesyncproto "github.com/anyproto/any-sync/commonspace/spacesyncproto"
|
||||
peer "github.com/anyproto/any-sync/net/peer"
|
||||
spacesyncproto "github.com/anytypeio/any-sync/commonspace/spacesyncproto"
|
||||
peer "github.com/anytypeio/any-sync/net/peer"
|
||||
gomock "github.com/golang/mock/gomock"
|
||||
)
|
||||
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
//go:generate mockgen -destination mock_peermanager/mock_peermanager.go github.com/anyproto/any-sync/commonspace/peermanager PeerManager
|
||||
//go:generate mockgen -destination mock_peermanager/mock_peermanager.go github.com/anytypeio/any-sync/commonspace/peermanager PeerManager
|
||||
package peermanager
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/anyproto/any-sync/app"
|
||||
"github.com/anyproto/any-sync/commonspace/spacesyncproto"
|
||||
"github.com/anyproto/any-sync/net/peer"
|
||||
"github.com/anytypeio/any-sync/app"
|
||||
"github.com/anytypeio/any-sync/commonspace/spacesyncproto"
|
||||
"github.com/anytypeio/any-sync/net/peer"
|
||||
)
|
||||
|
||||
const CName = "common.commonspace.peermanager"
|
||||
|
||||
@@ -2,10 +2,9 @@ package settings
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/anyproto/any-sync/commonspace/object/tree/treestorage"
|
||||
"github.com/anyproto/any-sync/commonspace/object/treemanager"
|
||||
"github.com/anyproto/any-sync/commonspace/settings/settingsstate"
|
||||
"github.com/anyproto/any-sync/commonspace/spacestorage"
|
||||
"github.com/anytypeio/any-sync/commonspace/object/treemanager"
|
||||
"github.com/anytypeio/any-sync/commonspace/settings/settingsstate"
|
||||
"github.com/anytypeio/any-sync/commonspace/spacestorage"
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
@@ -24,40 +23,17 @@ func newDeleter(st spacestorage.SpaceStorage, state settingsstate.ObjectDeletion
|
||||
}
|
||||
|
||||
func (d *deleter) Delete() {
|
||||
var (
|
||||
allQueued = d.state.GetQueued()
|
||||
spaceId = d.st.Id()
|
||||
)
|
||||
allQueued := d.state.GetQueued()
|
||||
for _, id := range allQueued {
|
||||
log := log.With(zap.String("treeId", id), zap.String("spaceId", spaceId))
|
||||
shouldDelete, err := d.tryMarkDeleted(spaceId, id)
|
||||
if !shouldDelete {
|
||||
if err != nil {
|
||||
log.Error("failed to mark object as deleted", zap.Error(err))
|
||||
continue
|
||||
}
|
||||
} else {
|
||||
err = d.getter.DeleteTree(context.Background(), spaceId, id)
|
||||
if err != nil && err != spacestorage.ErrTreeStorageAlreadyDeleted {
|
||||
log.Error("failed to delete object", zap.Error(err))
|
||||
continue
|
||||
}
|
||||
err := d.getter.DeleteTree(context.Background(), d.st.Id(), id)
|
||||
if err != nil && err != spacestorage.ErrTreeStorageAlreadyDeleted {
|
||||
log.With(zap.String("id", id), zap.Error(err)).Error("failed to delete object")
|
||||
continue
|
||||
}
|
||||
err = d.state.Delete(id)
|
||||
if err != nil {
|
||||
log.Error("failed to mark object as deleted", zap.Error(err))
|
||||
log.With(zap.String("id", id), zap.Error(err)).Error("failed to mark object as deleted")
|
||||
}
|
||||
log.Debug("object successfully deleted", zap.Error(err))
|
||||
log.With(zap.String("id", id), zap.Error(err)).Debug("object successfully deleted")
|
||||
}
|
||||
}
|
||||
|
||||
func (d *deleter) tryMarkDeleted(spaceId, treeId string) (bool, error) {
|
||||
_, err := d.st.TreeStorage(treeId)
|
||||
if err == nil {
|
||||
return true, nil
|
||||
}
|
||||
if err != treestorage.ErrUnknownTreeId {
|
||||
return false, err
|
||||
}
|
||||
return false, d.getter.MarkTreeDeleted(context.Background(), spaceId, treeId)
|
||||
}
|
||||
@@ -2,10 +2,10 @@ package settings
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/anyproto/any-sync/commonspace/object/tree/treestorage"
|
||||
"github.com/anyproto/any-sync/commonspace/object/treemanager/mock_treemanager"
|
||||
"github.com/anyproto/any-sync/commonspace/settings/settingsstate/mock_settingsstate"
|
||||
"github.com/anyproto/any-sync/commonspace/spacestorage/mock_spacestorage"
|
||||
"github.com/anytypeio/any-sync/commonspace/object/treemanager/mock_treemanager"
|
||||
"github.com/anytypeio/any-sync/commonspace/settings/settingsstate/mock_settingsstate"
|
||||
"github.com/anytypeio/any-sync/commonspace/spacestorage"
|
||||
"github.com/anytypeio/any-sync/commonspace/spacestorage/mock_spacestorage"
|
||||
"github.com/golang/mock/gomock"
|
||||
"testing"
|
||||
)
|
||||
@@ -18,46 +18,23 @@ func TestDeleter_Delete(t *testing.T) {
|
||||
|
||||
deleter := newDeleter(st, delState, treeManager)
|
||||
|
||||
t.Run("deleter delete mark deleted success", func(t *testing.T) {
|
||||
t.Run("deleter delete queued", func(t *testing.T) {
|
||||
id := "id"
|
||||
spaceId := "spaceId"
|
||||
delState.EXPECT().GetQueued().Return([]string{id})
|
||||
st.EXPECT().Id().Return(spaceId)
|
||||
st.EXPECT().TreeStorage(id).Return(nil, treestorage.ErrUnknownTreeId)
|
||||
treeManager.EXPECT().MarkTreeDeleted(gomock.Any(), spaceId, id).Return(nil)
|
||||
treeManager.EXPECT().DeleteTree(gomock.Any(), spaceId, id).Return(nil)
|
||||
delState.EXPECT().Delete(id).Return(nil)
|
||||
|
||||
deleter.Delete()
|
||||
})
|
||||
|
||||
t.Run("deleter delete mark deleted other error", func(t *testing.T) {
|
||||
t.Run("deleter delete already deleted", func(t *testing.T) {
|
||||
id := "id"
|
||||
spaceId := "spaceId"
|
||||
delState.EXPECT().GetQueued().Return([]string{id})
|
||||
st.EXPECT().Id().Return(spaceId)
|
||||
st.EXPECT().TreeStorage(id).Return(nil, fmt.Errorf("unknown error"))
|
||||
|
||||
deleter.Delete()
|
||||
})
|
||||
|
||||
t.Run("deleter delete mark deleted fail", func(t *testing.T) {
|
||||
id := "id"
|
||||
spaceId := "spaceId"
|
||||
delState.EXPECT().GetQueued().Return([]string{id})
|
||||
st.EXPECT().Id().Return(spaceId)
|
||||
st.EXPECT().TreeStorage(id).Return(nil, treestorage.ErrUnknownTreeId)
|
||||
treeManager.EXPECT().MarkTreeDeleted(gomock.Any(), spaceId, id).Return(fmt.Errorf("mark error"))
|
||||
|
||||
deleter.Delete()
|
||||
})
|
||||
//treeManager.EXPECT().DeleteTree(gomock.Any(), spaceId, id).Return(spacestorage.ErrTreeStorageAlreadyDeleted)
|
||||
t.Run("deleter delete success", func(t *testing.T) {
|
||||
id := "id"
|
||||
spaceId := "spaceId"
|
||||
delState.EXPECT().GetQueued().Return([]string{id})
|
||||
st.EXPECT().Id().Return(spaceId)
|
||||
st.EXPECT().TreeStorage(id).Return(nil, nil)
|
||||
treeManager.EXPECT().DeleteTree(gomock.Any(), spaceId, id).Return(nil)
|
||||
treeManager.EXPECT().DeleteTree(gomock.Any(), spaceId, id).Return(spacestorage.ErrTreeStorageAlreadyDeleted)
|
||||
delState.EXPECT().Delete(id).Return(nil)
|
||||
|
||||
deleter.Delete()
|
||||
@@ -68,7 +45,6 @@ func TestDeleter_Delete(t *testing.T) {
|
||||
spaceId := "spaceId"
|
||||
delState.EXPECT().GetQueued().Return([]string{id})
|
||||
st.EXPECT().Id().Return(spaceId)
|
||||
st.EXPECT().TreeStorage(id).Return(nil, nil)
|
||||
treeManager.EXPECT().DeleteTree(gomock.Any(), spaceId, id).Return(fmt.Errorf("some error"))
|
||||
|
||||
deleter.Delete()
|
||||
|
||||
@@ -2,8 +2,9 @@ package settings
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/anyproto/any-sync/commonspace/object/treemanager"
|
||||
"github.com/anyproto/any-sync/commonspace/settings/settingsstate"
|
||||
"github.com/anytypeio/any-sync/commonspace/object/treemanager"
|
||||
"github.com/anytypeio/any-sync/commonspace/settings/settingsstate"
|
||||
"github.com/anytypeio/any-sync/util/slice"
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
@@ -46,20 +47,22 @@ type deletionManager struct {
|
||||
|
||||
func (d *deletionManager) UpdateState(ctx context.Context, state *settingsstate.State) error {
|
||||
log := log.With(zap.String("spaceId", d.spaceId))
|
||||
d.deletionState.Add(state.DeletedIds)
|
||||
err := d.deletionState.Add(state.DeletedIds)
|
||||
if err != nil {
|
||||
log.Debug("failed to add deleted ids to deletion state")
|
||||
}
|
||||
if state.DeleterId == "" {
|
||||
return nil
|
||||
}
|
||||
// we should delete space
|
||||
log.Debug("deleting space")
|
||||
if d.isResponsible {
|
||||
mapIds := map[string]struct{}{}
|
||||
for _, id := range d.provider.AllIds() {
|
||||
if id != d.settingsId {
|
||||
mapIds[id] = struct{}{}
|
||||
}
|
||||
allIds := slice.DiscardFromSlice(d.provider.AllIds(), func(id string) bool {
|
||||
return id == d.settingsId
|
||||
})
|
||||
err := d.deletionState.Add(allIds)
|
||||
if err != nil {
|
||||
log.Debug("failed to add all ids to deletion state")
|
||||
}
|
||||
d.deletionState.Add(mapIds)
|
||||
}
|
||||
d.onSpaceDelete()
|
||||
return nil
|
||||
|
||||
@@ -2,10 +2,10 @@ package settings
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/anyproto/any-sync/commonspace/object/treemanager/mock_treemanager"
|
||||
"github.com/anyproto/any-sync/commonspace/settings/mock_settings"
|
||||
"github.com/anyproto/any-sync/commonspace/settings/settingsstate"
|
||||
"github.com/anyproto/any-sync/commonspace/settings/settingsstate/mock_settingsstate"
|
||||
"github.com/anytypeio/any-sync/commonspace/object/treemanager/mock_treemanager"
|
||||
"github.com/anytypeio/any-sync/commonspace/settings/mock_settings"
|
||||
"github.com/anytypeio/any-sync/commonspace/settings/settingsstate"
|
||||
"github.com/anytypeio/any-sync/commonspace/settings/settingsstate/mock_settingsstate"
|
||||
"github.com/golang/mock/gomock"
|
||||
"github.com/stretchr/testify/require"
|
||||
"testing"
|
||||
@@ -19,7 +19,7 @@ func TestDeletionManager_UpdateState_NotResponsible(t *testing.T) {
|
||||
spaceId := "spaceId"
|
||||
settingsId := "settingsId"
|
||||
state := &settingsstate.State{
|
||||
DeletedIds: map[string]struct{}{"id": {}},
|
||||
DeletedIds: []string{"id"},
|
||||
DeleterId: "deleterId",
|
||||
}
|
||||
deleted := false
|
||||
@@ -29,7 +29,7 @@ func TestDeletionManager_UpdateState_NotResponsible(t *testing.T) {
|
||||
delState := mock_settingsstate.NewMockObjectDeletionState(ctrl)
|
||||
treeManager := mock_treemanager.NewMockTreeManager(ctrl)
|
||||
|
||||
delState.EXPECT().Add(state.DeletedIds)
|
||||
delState.EXPECT().Add(state.DeletedIds).Return(nil)
|
||||
|
||||
delManager := newDeletionManager(spaceId,
|
||||
settingsId,
|
||||
@@ -51,7 +51,7 @@ func TestDeletionManager_UpdateState_Responsible(t *testing.T) {
|
||||
spaceId := "spaceId"
|
||||
settingsId := "settingsId"
|
||||
state := &settingsstate.State{
|
||||
DeletedIds: map[string]struct{}{"id": struct{}{}},
|
||||
DeletedIds: []string{"id"},
|
||||
DeleterId: "deleterId",
|
||||
}
|
||||
deleted := false
|
||||
@@ -62,9 +62,9 @@ func TestDeletionManager_UpdateState_Responsible(t *testing.T) {
|
||||
treeManager := mock_treemanager.NewMockTreeManager(ctrl)
|
||||
provider := mock_settings.NewMockSpaceIdsProvider(ctrl)
|
||||
|
||||
delState.EXPECT().Add(state.DeletedIds)
|
||||
delState.EXPECT().Add(state.DeletedIds).Return(nil)
|
||||
provider.EXPECT().AllIds().Return([]string{"id", "otherId", settingsId})
|
||||
delState.EXPECT().Add(map[string]struct{}{"id": {}, "otherId": {}})
|
||||
delState.EXPECT().Add([]string{"id", "otherId"}).Return(nil)
|
||||
delManager := newDeletionManager(spaceId,
|
||||
settingsId,
|
||||
true,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// Code generated by MockGen. DO NOT EDIT.
|
||||
// Source: github.com/anyproto/any-sync/commonspace/settings (interfaces: DeletionManager,Deleter,SpaceIdsProvider)
|
||||
// Source: github.com/anytypeio/any-sync/commonspace/settings (interfaces: DeletionManager,Deleter,SpaceIdsProvider)
|
||||
|
||||
// Package mock_settings is a generated GoMock package.
|
||||
package mock_settings
|
||||
@@ -8,7 +8,7 @@ import (
|
||||
context "context"
|
||||
reflect "reflect"
|
||||
|
||||
settingsstate "github.com/anyproto/any-sync/commonspace/settings/settingsstate"
|
||||
settingsstate "github.com/anytypeio/any-sync/commonspace/settings/settingsstate"
|
||||
gomock "github.com/golang/mock/gomock"
|
||||
)
|
||||
|
||||
|
||||
@@ -1,23 +1,23 @@
|
||||
//go:generate mockgen -destination mock_settings/mock_settings.go github.com/anyproto/any-sync/commonspace/settings DeletionManager,Deleter,SpaceIdsProvider
|
||||
//go:generate mockgen -destination mock_settings/mock_settings.go github.com/anytypeio/any-sync/commonspace/settings DeletionManager,Deleter,SpaceIdsProvider
|
||||
package settings
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"github.com/anyproto/any-sync/util/crypto"
|
||||
"github.com/anytypeio/any-sync/util/crypto"
|
||||
|
||||
"github.com/anyproto/any-sync/accountservice"
|
||||
"github.com/anyproto/any-sync/app/logger"
|
||||
"github.com/anyproto/any-sync/commonspace/object/tree/objecttree"
|
||||
"github.com/anyproto/any-sync/commonspace/object/tree/synctree"
|
||||
"github.com/anyproto/any-sync/commonspace/object/tree/synctree/updatelistener"
|
||||
"github.com/anyproto/any-sync/commonspace/object/tree/treechangeproto"
|
||||
"github.com/anyproto/any-sync/commonspace/object/treemanager"
|
||||
"github.com/anyproto/any-sync/commonspace/settings/settingsstate"
|
||||
"github.com/anyproto/any-sync/commonspace/spacestorage"
|
||||
"github.com/anyproto/any-sync/commonspace/spacesyncproto"
|
||||
"github.com/anyproto/any-sync/nodeconf"
|
||||
"github.com/anytypeio/any-sync/accountservice"
|
||||
"github.com/anytypeio/any-sync/app/logger"
|
||||
"github.com/anytypeio/any-sync/commonspace/object/tree/objecttree"
|
||||
"github.com/anytypeio/any-sync/commonspace/object/tree/synctree"
|
||||
"github.com/anytypeio/any-sync/commonspace/object/tree/synctree/updatelistener"
|
||||
"github.com/anytypeio/any-sync/commonspace/object/tree/treechangeproto"
|
||||
"github.com/anytypeio/any-sync/commonspace/object/treemanager"
|
||||
"github.com/anytypeio/any-sync/commonspace/settings/settingsstate"
|
||||
"github.com/anytypeio/any-sync/commonspace/spacestorage"
|
||||
"github.com/anytypeio/any-sync/commonspace/spacesyncproto"
|
||||
"github.com/anytypeio/any-sync/nodeconf"
|
||||
"github.com/gogo/protobuf/proto"
|
||||
"go.uber.org/zap"
|
||||
"golang.org/x/exp/slices"
|
||||
@@ -40,16 +40,7 @@ var (
|
||||
ErrCantDeleteSpace = errors.New("not able to delete space")
|
||||
)
|
||||
|
||||
var (
|
||||
DoSnapshot = objecttree.DoSnapshot
|
||||
buildHistoryTree = func(objTree objecttree.ObjectTree) (objecttree.ReadableObjectTree, error) {
|
||||
return objecttree.BuildHistoryTree(objecttree.HistoryTreeParams{
|
||||
TreeStorage: objTree.Storage(),
|
||||
AclList: objTree.AclList(),
|
||||
BuildFullTree: true,
|
||||
})
|
||||
}
|
||||
)
|
||||
var doSnapshot = objecttree.DoSnapshot
|
||||
|
||||
type BuildTreeFunc func(ctx context.Context, id string, listener updatelistener.UpdateListener) (t synctree.SyncTree, err error)
|
||||
|
||||
@@ -175,33 +166,8 @@ func (s *settingsObject) Init(ctx context.Context) (err error) {
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
// TODO: remove this check when everybody updates
|
||||
if err = s.checkHistoryState(ctx); err != nil {
|
||||
return
|
||||
}
|
||||
s.loop.Run()
|
||||
return
|
||||
}
|
||||
|
||||
func (s *settingsObject) checkHistoryState(ctx context.Context) (err error) {
|
||||
historyTree, err := buildHistoryTree(s.SyncTree)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
fullState, err := s.builder.Build(historyTree, nil)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
if len(fullState.DeletedIds) != len(s.state.DeletedIds) {
|
||||
log.WarnCtx(ctx, "state does not have all deleted ids",
|
||||
zap.Int("fullstate ids", len(fullState.DeletedIds)),
|
||||
zap.Int("state ids", len(fullState.DeletedIds)))
|
||||
s.state = fullState
|
||||
err = s.deletionManager.UpdateState(context.Background(), s.state)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
s.loop.Run()
|
||||
return
|
||||
}
|
||||
|
||||
@@ -255,7 +221,7 @@ func (s *settingsObject) DeleteObject(id string) (err error) {
|
||||
err = ErrDeleteSelf
|
||||
return
|
||||
}
|
||||
if s.state.Exists(id) {
|
||||
if s.deletionState.Exists(id) {
|
||||
err = ErrAlreadyDeleted
|
||||
return nil
|
||||
}
|
||||
@@ -264,7 +230,7 @@ func (s *settingsObject) DeleteObject(id string) (err error) {
|
||||
err = ErrObjDoesNotExist
|
||||
return
|
||||
}
|
||||
isSnapshot := DoSnapshot(s.Len())
|
||||
isSnapshot := doSnapshot(s.Len())
|
||||
res, err := s.changeFactory.CreateObjectDeleteChange(id, s.state, isSnapshot)
|
||||
if err != nil {
|
||||
return
|
||||
@@ -283,7 +249,7 @@ func (s *settingsObject) verifyDeleteSpace(raw *treechangeproto.RawTreeChangeWit
|
||||
|
||||
func (s *settingsObject) addContent(data []byte, isSnapshot bool) (err error) {
|
||||
accountData := s.account.Account()
|
||||
res, err := s.AddContent(context.Background(), objecttree.SignableChangeContent{
|
||||
_, err = s.AddContent(context.Background(), objecttree.SignableChangeContent{
|
||||
Data: data,
|
||||
Key: accountData.SignKey,
|
||||
IsSnapshot: isSnapshot,
|
||||
@@ -292,11 +258,8 @@ func (s *settingsObject) addContent(data []byte, isSnapshot bool) (err error) {
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
if res.Mode == objecttree.Rebuild {
|
||||
s.Rebuild(s)
|
||||
} else {
|
||||
s.Update(s)
|
||||
}
|
||||
|
||||
s.Update(s)
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -2,19 +2,18 @@ package settings
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/anyproto/any-sync/accountservice/mock_accountservice"
|
||||
"github.com/anyproto/any-sync/commonspace/object/accountdata"
|
||||
"github.com/anyproto/any-sync/commonspace/object/tree/objecttree"
|
||||
"github.com/anyproto/any-sync/commonspace/object/tree/objecttree/mock_objecttree"
|
||||
"github.com/anyproto/any-sync/commonspace/object/tree/synctree"
|
||||
"github.com/anyproto/any-sync/commonspace/object/tree/synctree/mock_synctree"
|
||||
"github.com/anyproto/any-sync/commonspace/object/tree/synctree/updatelistener"
|
||||
"github.com/anyproto/any-sync/commonspace/object/tree/treechangeproto"
|
||||
"github.com/anyproto/any-sync/commonspace/object/treemanager/mock_treemanager"
|
||||
"github.com/anyproto/any-sync/commonspace/settings/mock_settings"
|
||||
"github.com/anyproto/any-sync/commonspace/settings/settingsstate"
|
||||
"github.com/anyproto/any-sync/commonspace/settings/settingsstate/mock_settingsstate"
|
||||
"github.com/anyproto/any-sync/commonspace/spacestorage/mock_spacestorage"
|
||||
"github.com/anytypeio/any-sync/accountservice/mock_accountservice"
|
||||
"github.com/anytypeio/any-sync/commonspace/object/accountdata"
|
||||
"github.com/anytypeio/any-sync/commonspace/object/tree/objecttree"
|
||||
"github.com/anytypeio/any-sync/commonspace/object/tree/synctree"
|
||||
"github.com/anytypeio/any-sync/commonspace/object/tree/synctree/mock_synctree"
|
||||
"github.com/anytypeio/any-sync/commonspace/object/tree/synctree/updatelistener"
|
||||
"github.com/anytypeio/any-sync/commonspace/object/tree/treechangeproto"
|
||||
"github.com/anytypeio/any-sync/commonspace/object/treemanager/mock_treemanager"
|
||||
"github.com/anytypeio/any-sync/commonspace/settings/mock_settings"
|
||||
"github.com/anytypeio/any-sync/commonspace/settings/settingsstate"
|
||||
"github.com/anytypeio/any-sync/commonspace/settings/settingsstate/mock_settingsstate"
|
||||
"github.com/anytypeio/any-sync/commonspace/spacestorage/mock_spacestorage"
|
||||
"github.com/golang/mock/gomock"
|
||||
"github.com/stretchr/testify/require"
|
||||
"sync"
|
||||
@@ -53,7 +52,6 @@ type settingsFixture struct {
|
||||
changeFactory *mock_settingsstate.MockChangeFactory
|
||||
deleter *mock_settings.MockDeleter
|
||||
syncTree *mock_synctree.MockSyncTree
|
||||
historyTree *mock_objecttree.MockObjectTree
|
||||
delState *mock_settingsstate.MockObjectDeletionState
|
||||
account *mock_accountservice.MockService
|
||||
}
|
||||
@@ -71,7 +69,6 @@ func newSettingsFixture(t *testing.T) *settingsFixture {
|
||||
stateBuilder := mock_settingsstate.NewMockStateBuilder(ctrl)
|
||||
changeFactory := mock_settingsstate.NewMockChangeFactory(ctrl)
|
||||
syncTree := mock_synctree.NewMockSyncTree(ctrl)
|
||||
historyTree := mock_objecttree.NewMockObjectTree(ctrl)
|
||||
del := mock_settings.NewMockDeleter(ctrl)
|
||||
|
||||
delState.EXPECT().AddObserver(gomock.Any())
|
||||
@@ -80,9 +77,6 @@ func newSettingsFixture(t *testing.T) *settingsFixture {
|
||||
require.Equal(t, objectId, id)
|
||||
return newTestObjMock(syncTree), nil
|
||||
})
|
||||
buildHistoryTree = func(objTree objecttree.ObjectTree) (objecttree.ReadableObjectTree, error) {
|
||||
return historyTree, nil
|
||||
}
|
||||
|
||||
deps := Deps{
|
||||
BuildFunc: buildFunc,
|
||||
@@ -110,48 +104,45 @@ func newSettingsFixture(t *testing.T) *settingsFixture {
|
||||
syncTree: syncTree,
|
||||
account: acc,
|
||||
delState: delState,
|
||||
historyTree: historyTree,
|
||||
}
|
||||
}
|
||||
|
||||
func (fx *settingsFixture) init(t *testing.T) {
|
||||
fx.spaceStorage.EXPECT().SpaceSettingsId().Return(fx.docId)
|
||||
fx.deleter.EXPECT().Delete()
|
||||
fx.stateBuilder.EXPECT().Build(fx.historyTree, nil).Return(&settingsstate.State{}, nil)
|
||||
fx.doc.state = &settingsstate.State{}
|
||||
|
||||
err := fx.doc.Init(context.Background())
|
||||
require.NoError(t, err)
|
||||
}
|
||||
|
||||
func (fx *settingsFixture) stop(t *testing.T) {
|
||||
fx.syncTree.EXPECT().Close().Return(nil)
|
||||
|
||||
err := fx.doc.Close()
|
||||
require.NoError(t, err)
|
||||
func (fx *settingsFixture) stop() {
|
||||
fx.ctrl.Finish()
|
||||
}
|
||||
|
||||
func TestSettingsObject_Init(t *testing.T) {
|
||||
fx := newSettingsFixture(t)
|
||||
defer fx.stop(t)
|
||||
defer fx.stop()
|
||||
|
||||
fx.init(t)
|
||||
fx.spaceStorage.EXPECT().SpaceSettingsId().Return(fx.docId)
|
||||
fx.deleter.EXPECT().Delete()
|
||||
fx.syncTree.EXPECT().Close().Return(nil)
|
||||
|
||||
err := fx.doc.Init(context.Background())
|
||||
require.NoError(t, err)
|
||||
err = fx.doc.Close()
|
||||
require.NoError(t, err)
|
||||
}
|
||||
|
||||
func TestSettingsObject_DeleteObject_NoSnapshot(t *testing.T) {
|
||||
fx := newSettingsFixture(t)
|
||||
defer fx.stop(t)
|
||||
defer fx.stop()
|
||||
|
||||
fx.init(t)
|
||||
fx.spaceStorage.EXPECT().SpaceSettingsId().Return(fx.docId)
|
||||
fx.deleter.EXPECT().Delete()
|
||||
|
||||
err := fx.doc.Init(context.Background())
|
||||
require.NoError(t, err)
|
||||
|
||||
delId := "delId"
|
||||
DoSnapshot = func(len int) bool {
|
||||
doSnapshot = func(len int) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
fx.syncTree.EXPECT().Id().Return("syncId")
|
||||
fx.syncTree.EXPECT().Len().Return(10)
|
||||
fx.delState.EXPECT().Exists(delId).Return(false)
|
||||
fx.spaceStorage.EXPECT().TreeStorage(delId).Return(nil, nil)
|
||||
res := []byte("settingsData")
|
||||
fx.doc.state = &settingsstate.State{LastIteratedId: "someId"}
|
||||
@@ -171,20 +162,30 @@ func TestSettingsObject_DeleteObject_NoSnapshot(t *testing.T) {
|
||||
fx.deletionManager.EXPECT().UpdateState(gomock.Any(), fx.doc.state).Return(nil)
|
||||
err = fx.doc.DeleteObject(delId)
|
||||
require.NoError(t, err)
|
||||
|
||||
fx.syncTree.EXPECT().Close().Return(nil)
|
||||
err = fx.doc.Close()
|
||||
require.NoError(t, err)
|
||||
}
|
||||
|
||||
func TestSettingsObject_DeleteObject_WithSnapshot(t *testing.T) {
|
||||
fx := newSettingsFixture(t)
|
||||
defer fx.stop(t)
|
||||
defer fx.stop()
|
||||
|
||||
fx.spaceStorage.EXPECT().SpaceSettingsId().Return(fx.docId)
|
||||
fx.deleter.EXPECT().Delete()
|
||||
|
||||
err := fx.doc.Init(context.Background())
|
||||
require.NoError(t, err)
|
||||
|
||||
fx.init(t)
|
||||
delId := "delId"
|
||||
DoSnapshot = func(len int) bool {
|
||||
doSnapshot = func(len int) bool {
|
||||
return true
|
||||
}
|
||||
|
||||
fx.syncTree.EXPECT().Id().Return("syncId")
|
||||
fx.syncTree.EXPECT().Len().Return(10)
|
||||
fx.delState.EXPECT().Exists(delId).Return(false)
|
||||
fx.spaceStorage.EXPECT().TreeStorage(delId).Return(nil, nil)
|
||||
res := []byte("settingsData")
|
||||
fx.doc.state = &settingsstate.State{LastIteratedId: "someId"}
|
||||
@@ -198,19 +199,27 @@ func TestSettingsObject_DeleteObject_WithSnapshot(t *testing.T) {
|
||||
Key: accountData.SignKey,
|
||||
IsSnapshot: true,
|
||||
IsEncrypted: false,
|
||||
}).Return(objecttree.AddResult{Mode: objecttree.Rebuild}, nil)
|
||||
}).Return(objecttree.AddResult{}, nil)
|
||||
|
||||
fx.stateBuilder.EXPECT().Build(fx.doc, nil).Return(fx.doc.state, nil)
|
||||
fx.stateBuilder.EXPECT().Build(fx.doc, fx.doc.state).Return(fx.doc.state, nil)
|
||||
fx.deletionManager.EXPECT().UpdateState(gomock.Any(), fx.doc.state).Return(nil)
|
||||
err = fx.doc.DeleteObject(delId)
|
||||
require.NoError(t, err)
|
||||
|
||||
fx.syncTree.EXPECT().Close().Return(nil)
|
||||
err = fx.doc.Close()
|
||||
require.NoError(t, err)
|
||||
}
|
||||
|
||||
func TestSettingsObject_Rebuild(t *testing.T) {
|
||||
fx := newSettingsFixture(t)
|
||||
defer fx.stop(t)
|
||||
defer fx.stop()
|
||||
|
||||
fx.init(t)
|
||||
fx.spaceStorage.EXPECT().SpaceSettingsId().Return(fx.docId)
|
||||
fx.deleter.EXPECT().Delete()
|
||||
|
||||
err := fx.doc.Init(context.Background())
|
||||
require.NoError(t, err)
|
||||
time.Sleep(100 * time.Millisecond)
|
||||
|
||||
newSt := &settingsstate.State{}
|
||||
@@ -223,9 +232,13 @@ func TestSettingsObject_Rebuild(t *testing.T) {
|
||||
|
||||
func TestSettingsObject_Update(t *testing.T) {
|
||||
fx := newSettingsFixture(t)
|
||||
defer fx.stop(t)
|
||||
defer fx.stop()
|
||||
|
||||
fx.init(t)
|
||||
fx.spaceStorage.EXPECT().SpaceSettingsId().Return(fx.docId)
|
||||
fx.deleter.EXPECT().Delete()
|
||||
|
||||
err := fx.doc.Init(context.Background())
|
||||
require.NoError(t, err)
|
||||
time.Sleep(100 * time.Millisecond)
|
||||
|
||||
fx.doc.state = &settingsstate.State{}
|
||||
@@ -237,9 +250,13 @@ func TestSettingsObject_Update(t *testing.T) {
|
||||
|
||||
func TestSettingsObject_DeleteSpace(t *testing.T) {
|
||||
fx := newSettingsFixture(t)
|
||||
defer fx.stop(t)
|
||||
defer fx.stop()
|
||||
|
||||
fx.init(t)
|
||||
fx.spaceStorage.EXPECT().SpaceSettingsId().Return(fx.docId)
|
||||
fx.deleter.EXPECT().Delete()
|
||||
|
||||
err := fx.doc.Init(context.Background())
|
||||
require.NoError(t, err)
|
||||
time.Sleep(100 * time.Millisecond)
|
||||
|
||||
deleterId := "delId"
|
||||
@@ -258,15 +275,19 @@ func TestSettingsObject_DeleteSpace(t *testing.T) {
|
||||
Heads: []string{rawCh.Id},
|
||||
}, nil)
|
||||
|
||||
err := fx.doc.DeleteSpace(context.Background(), rawCh)
|
||||
err = fx.doc.DeleteSpace(context.Background(), rawCh)
|
||||
require.NoError(t, err)
|
||||
}
|
||||
|
||||
func TestSettingsObject_DeleteSpaceIncorrectChange(t *testing.T) {
|
||||
fx := newSettingsFixture(t)
|
||||
defer fx.stop(t)
|
||||
defer fx.stop()
|
||||
|
||||
fx.init(t)
|
||||
fx.spaceStorage.EXPECT().SpaceSettingsId().Return(fx.docId)
|
||||
fx.deleter.EXPECT().Delete()
|
||||
|
||||
err := fx.doc.Init(context.Background())
|
||||
require.NoError(t, err)
|
||||
time.Sleep(100 * time.Millisecond)
|
||||
|
||||
t.Run("incorrect change type", func(t *testing.T) {
|
||||
@@ -278,7 +299,7 @@ func TestSettingsObject_DeleteSpaceIncorrectChange(t *testing.T) {
|
||||
delChange, _ := changeFactory.CreateObjectDeleteChange("otherId", &settingsstate.State{}, false)
|
||||
|
||||
fx.syncTree.EXPECT().UnpackChange(rawCh).Return(delChange, nil)
|
||||
err := fx.doc.DeleteSpace(context.Background(), rawCh)
|
||||
err = fx.doc.DeleteSpace(context.Background(), rawCh)
|
||||
require.NotNil(t, err)
|
||||
})
|
||||
|
||||
@@ -291,7 +312,7 @@ func TestSettingsObject_DeleteSpaceIncorrectChange(t *testing.T) {
|
||||
delChange, _ := changeFactory.CreateSpaceDeleteChange("", &settingsstate.State{}, false)
|
||||
|
||||
fx.syncTree.EXPECT().UnpackChange(rawCh).Return(delChange, nil)
|
||||
err := fx.doc.DeleteSpace(context.Background(), rawCh)
|
||||
err = fx.doc.DeleteSpace(context.Background(), rawCh)
|
||||
require.NotNil(t, err)
|
||||
})
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
package settingsstate
|
||||
|
||||
import (
|
||||
"github.com/anyproto/any-sync/commonspace/spacesyncproto"
|
||||
"github.com/anytypeio/any-sync/commonspace/spacesyncproto"
|
||||
)
|
||||
|
||||
type ChangeFactory interface {
|
||||
@@ -50,7 +50,7 @@ func (c *changeFactory) CreateSpaceDeleteChange(peerId string, state *State, isS
|
||||
|
||||
func (c *changeFactory) makeSnapshot(state *State, objectId, deleterPeer string) *spacesyncproto.SpaceSettingsSnapshot {
|
||||
var (
|
||||
deletedIds = make([]string, 0, len(state.DeletedIds)+1)
|
||||
deletedIds = state.DeletedIds
|
||||
deleterId = state.DeleterId
|
||||
)
|
||||
if objectId != "" {
|
||||
@@ -59,9 +59,6 @@ func (c *changeFactory) makeSnapshot(state *State, objectId, deleterPeer string)
|
||||
if deleterPeer != "" {
|
||||
deleterId = deleterPeer
|
||||
}
|
||||
for id := range state.DeletedIds {
|
||||
deletedIds = append(deletedIds, id)
|
||||
}
|
||||
return &spacesyncproto.SpaceSettingsSnapshot{
|
||||
DeletedIds: deletedIds,
|
||||
DeleterPeerId: deleterId,
|
||||
|
||||
@@ -1,17 +1,16 @@
|
||||
package settingsstate
|
||||
|
||||
import (
|
||||
"github.com/anyproto/any-sync/commonspace/spacesyncproto"
|
||||
"github.com/anytypeio/any-sync/commonspace/spacesyncproto"
|
||||
"github.com/gogo/protobuf/proto"
|
||||
"github.com/stretchr/testify/require"
|
||||
"golang.org/x/exp/slices"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestChangeFactory_CreateObjectDeleteChange(t *testing.T) {
|
||||
factory := NewChangeFactory()
|
||||
state := &State{
|
||||
DeletedIds: map[string]struct{}{"1": {}, "2": {}},
|
||||
DeletedIds: []string{"1", "2"},
|
||||
DeleterId: "del",
|
||||
}
|
||||
marshalled, err := factory.CreateObjectDeleteChange("3", state, false)
|
||||
@@ -27,7 +26,6 @@ func TestChangeFactory_CreateObjectDeleteChange(t *testing.T) {
|
||||
data = &spacesyncproto.SettingsData{}
|
||||
err = proto.Unmarshal(marshalled, data)
|
||||
require.NoError(t, err)
|
||||
slices.Sort(data.Snapshot.DeletedIds)
|
||||
require.Equal(t, &spacesyncproto.SpaceSettingsSnapshot{
|
||||
DeletedIds: []string{"1", "2", "3"},
|
||||
DeleterPeerId: "del",
|
||||
@@ -38,7 +36,7 @@ func TestChangeFactory_CreateObjectDeleteChange(t *testing.T) {
|
||||
func TestChangeFactory_CreateSpaceDeleteChange(t *testing.T) {
|
||||
factory := NewChangeFactory()
|
||||
state := &State{
|
||||
DeletedIds: map[string]struct{}{"1": {}, "2": {}},
|
||||
DeletedIds: []string{"1", "2"},
|
||||
}
|
||||
marshalled, err := factory.CreateSpaceDeleteChange("del", state, false)
|
||||
require.NoError(t, err)
|
||||
@@ -53,7 +51,6 @@ func TestChangeFactory_CreateSpaceDeleteChange(t *testing.T) {
|
||||
data = &spacesyncproto.SettingsData{}
|
||||
err = proto.Unmarshal(marshalled, data)
|
||||
require.NoError(t, err)
|
||||
slices.Sort(data.Snapshot.DeletedIds)
|
||||
require.Equal(t, &spacesyncproto.SpaceSettingsSnapshot{
|
||||
DeletedIds: []string{"1", "2"},
|
||||
DeleterPeerId: "del",
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
//go:generate mockgen -destination mock_settingsstate/mock_settingsstate.go github.com/anyproto/any-sync/commonspace/settings/settingsstate ObjectDeletionState,StateBuilder,ChangeFactory
|
||||
//go:generate mockgen -destination mock_settingsstate/mock_settingsstate.go github.com/anytypeio/any-sync/commonspace/settings/settingsstate ObjectDeletionState,StateBuilder,ChangeFactory
|
||||
package settingsstate
|
||||
|
||||
import (
|
||||
"github.com/anyproto/any-sync/app/logger"
|
||||
"github.com/anyproto/any-sync/commonspace/spacestorage"
|
||||
"go.uber.org/zap"
|
||||
"github.com/anytypeio/any-sync/commonspace/spacestorage"
|
||||
"sync"
|
||||
)
|
||||
|
||||
@@ -12,25 +10,23 @@ type StateUpdateObserver func(ids []string)
|
||||
|
||||
type ObjectDeletionState interface {
|
||||
AddObserver(observer StateUpdateObserver)
|
||||
Add(ids map[string]struct{})
|
||||
Add(ids []string) (err error)
|
||||
GetQueued() (ids []string)
|
||||
Delete(id string) (err error)
|
||||
Exists(id string) bool
|
||||
Filter(ids []string) (filtered []string)
|
||||
FilterJoin(ids ...[]string) (filtered []string)
|
||||
}
|
||||
|
||||
type objectDeletionState struct {
|
||||
sync.RWMutex
|
||||
log logger.CtxLogger
|
||||
queued map[string]struct{}
|
||||
deleted map[string]struct{}
|
||||
stateUpdateObservers []StateUpdateObserver
|
||||
storage spacestorage.SpaceStorage
|
||||
}
|
||||
|
||||
func NewObjectDeletionState(log logger.CtxLogger, storage spacestorage.SpaceStorage) ObjectDeletionState {
|
||||
func NewObjectDeletionState(storage spacestorage.SpaceStorage) ObjectDeletionState {
|
||||
return &objectDeletionState{
|
||||
log: log,
|
||||
queued: map[string]struct{}{},
|
||||
deleted: map[string]struct{}{},
|
||||
storage: storage,
|
||||
@@ -43,17 +39,19 @@ func (st *objectDeletionState) AddObserver(observer StateUpdateObserver) {
|
||||
st.stateUpdateObservers = append(st.stateUpdateObservers, observer)
|
||||
}
|
||||
|
||||
func (st *objectDeletionState) Add(ids map[string]struct{}) {
|
||||
var added []string
|
||||
func (st *objectDeletionState) Add(ids []string) (err error) {
|
||||
st.Lock()
|
||||
defer func() {
|
||||
st.Unlock()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
for _, ob := range st.stateUpdateObservers {
|
||||
ob(added)
|
||||
ob(ids)
|
||||
}
|
||||
}()
|
||||
|
||||
for id := range ids {
|
||||
for _, id := range ids {
|
||||
if _, exists := st.deleted[id]; exists {
|
||||
continue
|
||||
}
|
||||
@@ -62,10 +60,9 @@ func (st *objectDeletionState) Add(ids map[string]struct{}) {
|
||||
}
|
||||
|
||||
var status string
|
||||
status, err := st.storage.TreeDeletedStatus(id)
|
||||
status, err = st.storage.TreeDeletedStatus(id)
|
||||
if err != nil {
|
||||
st.log.Warn("failed to get deleted status", zap.String("treeId", id), zap.Error(err))
|
||||
continue
|
||||
return
|
||||
}
|
||||
|
||||
switch status {
|
||||
@@ -74,15 +71,14 @@ func (st *objectDeletionState) Add(ids map[string]struct{}) {
|
||||
case spacestorage.TreeDeletedStatusDeleted:
|
||||
st.deleted[id] = struct{}{}
|
||||
default:
|
||||
err := st.storage.SetTreeDeletedStatus(id, spacestorage.TreeDeletedStatusQueued)
|
||||
if err != nil {
|
||||
st.log.Warn("failed to set deleted status", zap.String("treeId", id), zap.Error(err))
|
||||
continue
|
||||
}
|
||||
st.queued[id] = struct{}{}
|
||||
err = st.storage.SetTreeDeletedStatus(id, spacestorage.TreeDeletedStatusQueued)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
added = append(added, id)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func (st *objectDeletionState) GetQueued() (ids []string) {
|
||||
@@ -113,14 +109,19 @@ func (st *objectDeletionState) Exists(id string) bool {
|
||||
return st.exists(id)
|
||||
}
|
||||
|
||||
func (st *objectDeletionState) Filter(ids []string) (filtered []string) {
|
||||
func (st *objectDeletionState) FilterJoin(ids ...[]string) (filtered []string) {
|
||||
st.RLock()
|
||||
defer st.RUnlock()
|
||||
for _, id := range ids {
|
||||
if !st.exists(id) {
|
||||
filtered = append(filtered, id)
|
||||
filter := func(ids []string) {
|
||||
for _, id := range ids {
|
||||
if !st.exists(id) {
|
||||
filtered = append(filtered, id)
|
||||
}
|
||||
}
|
||||
}
|
||||
for _, arr := range ids {
|
||||
filter(arr)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
package settingsstate
|
||||
|
||||
import (
|
||||
"github.com/anyproto/any-sync/app/logger"
|
||||
"github.com/anyproto/any-sync/commonspace/spacestorage"
|
||||
"github.com/anyproto/any-sync/commonspace/spacestorage/mock_spacestorage"
|
||||
"github.com/anytypeio/any-sync/commonspace/spacestorage"
|
||||
"github.com/anytypeio/any-sync/commonspace/spacestorage/mock_spacestorage"
|
||||
"github.com/golang/mock/gomock"
|
||||
"github.com/stretchr/testify/require"
|
||||
"sort"
|
||||
@@ -19,7 +18,7 @@ type fixture struct {
|
||||
func newFixture(t *testing.T) *fixture {
|
||||
ctrl := gomock.NewController(t)
|
||||
spaceStorage := mock_spacestorage.NewMockSpaceStorage(ctrl)
|
||||
delState := NewObjectDeletionState(logger.NewNamed("test"), spaceStorage).(*objectDeletionState)
|
||||
delState := NewObjectDeletionState(spaceStorage).(*objectDeletionState)
|
||||
return &fixture{
|
||||
ctrl: ctrl,
|
||||
delState: delState,
|
||||
@@ -38,7 +37,8 @@ func TestDeletionState_Add(t *testing.T) {
|
||||
id := "newId"
|
||||
fx.spaceStorage.EXPECT().TreeDeletedStatus(id).Return("", nil)
|
||||
fx.spaceStorage.EXPECT().SetTreeDeletedStatus(id, spacestorage.TreeDeletedStatusQueued).Return(nil)
|
||||
fx.delState.Add(map[string]struct{}{id: {}})
|
||||
err := fx.delState.Add([]string{id})
|
||||
require.NoError(t, err)
|
||||
require.Contains(t, fx.delState.queued, id)
|
||||
})
|
||||
|
||||
@@ -47,7 +47,8 @@ func TestDeletionState_Add(t *testing.T) {
|
||||
defer fx.stop()
|
||||
id := "newId"
|
||||
fx.spaceStorage.EXPECT().TreeDeletedStatus(id).Return(spacestorage.TreeDeletedStatusQueued, nil)
|
||||
fx.delState.Add(map[string]struct{}{id: {}})
|
||||
err := fx.delState.Add([]string{id})
|
||||
require.NoError(t, err)
|
||||
require.Contains(t, fx.delState.queued, id)
|
||||
})
|
||||
|
||||
@@ -56,7 +57,8 @@ func TestDeletionState_Add(t *testing.T) {
|
||||
defer fx.stop()
|
||||
id := "newId"
|
||||
fx.spaceStorage.EXPECT().TreeDeletedStatus(id).Return(spacestorage.TreeDeletedStatusDeleted, nil)
|
||||
fx.delState.Add(map[string]struct{}{id: {}})
|
||||
err := fx.delState.Add([]string{id})
|
||||
require.NoError(t, err)
|
||||
require.Contains(t, fx.delState.deleted, id)
|
||||
})
|
||||
}
|
||||
@@ -80,8 +82,8 @@ func TestDeletionState_FilterJoin(t *testing.T) {
|
||||
fx.delState.queued["id1"] = struct{}{}
|
||||
fx.delState.queued["id2"] = struct{}{}
|
||||
|
||||
filtered := fx.delState.Filter([]string{"id3", "id2"})
|
||||
require.Equal(t, []string{"id3"}, filtered)
|
||||
filtered := fx.delState.FilterJoin([]string{"id1"}, []string{"id3", "id2"}, []string{"id4"})
|
||||
require.Equal(t, []string{"id3", "id4"}, filtered)
|
||||
}
|
||||
|
||||
func TestDeletionState_AddObserver(t *testing.T) {
|
||||
@@ -96,7 +98,8 @@ func TestDeletionState_AddObserver(t *testing.T) {
|
||||
id := "newId"
|
||||
fx.spaceStorage.EXPECT().TreeDeletedStatus(id).Return("", nil)
|
||||
fx.spaceStorage.EXPECT().SetTreeDeletedStatus(id, spacestorage.TreeDeletedStatusQueued).Return(nil)
|
||||
fx.delState.Add(map[string]struct{}{id: {}})
|
||||
err := fx.delState.Add([]string{id})
|
||||
require.NoError(t, err)
|
||||
require.Contains(t, fx.delState.queued, id)
|
||||
require.Equal(t, []string{id}, queued)
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// Code generated by MockGen. DO NOT EDIT.
|
||||
// Source: github.com/anyproto/any-sync/commonspace/settings/settingsstate (interfaces: ObjectDeletionState,StateBuilder,ChangeFactory)
|
||||
// Source: github.com/anytypeio/any-sync/commonspace/settings/settingsstate (interfaces: ObjectDeletionState,StateBuilder,ChangeFactory)
|
||||
|
||||
// Package mock_settingsstate is a generated GoMock package.
|
||||
package mock_settingsstate
|
||||
@@ -7,8 +7,8 @@ package mock_settingsstate
|
||||
import (
|
||||
reflect "reflect"
|
||||
|
||||
objecttree "github.com/anyproto/any-sync/commonspace/object/tree/objecttree"
|
||||
settingsstate "github.com/anyproto/any-sync/commonspace/settings/settingsstate"
|
||||
objecttree "github.com/anytypeio/any-sync/commonspace/object/tree/objecttree"
|
||||
settingsstate "github.com/anytypeio/any-sync/commonspace/settings/settingsstate"
|
||||
gomock "github.com/golang/mock/gomock"
|
||||
)
|
||||
|
||||
@@ -36,9 +36,11 @@ func (m *MockObjectDeletionState) EXPECT() *MockObjectDeletionStateMockRecorder
|
||||
}
|
||||
|
||||
// Add mocks base method.
|
||||
func (m *MockObjectDeletionState) Add(arg0 map[string]struct{}) {
|
||||
func (m *MockObjectDeletionState) Add(arg0 []string) error {
|
||||
m.ctrl.T.Helper()
|
||||
m.ctrl.Call(m, "Add", arg0)
|
||||
ret := m.ctrl.Call(m, "Add", arg0)
|
||||
ret0, _ := ret[0].(error)
|
||||
return ret0
|
||||
}
|
||||
|
||||
// Add indicates an expected call of Add.
|
||||
@@ -87,18 +89,22 @@ func (mr *MockObjectDeletionStateMockRecorder) Exists(arg0 interface{}) *gomock.
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Exists", reflect.TypeOf((*MockObjectDeletionState)(nil).Exists), arg0)
|
||||
}
|
||||
|
||||
// Filter mocks base method.
|
||||
func (m *MockObjectDeletionState) Filter(arg0 []string) []string {
|
||||
// FilterJoin mocks base method.
|
||||
func (m *MockObjectDeletionState) FilterJoin(arg0 ...[]string) []string {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "Filter", arg0)
|
||||
varargs := []interface{}{}
|
||||
for _, a := range arg0 {
|
||||
varargs = append(varargs, a)
|
||||
}
|
||||
ret := m.ctrl.Call(m, "FilterJoin", varargs...)
|
||||
ret0, _ := ret[0].([]string)
|
||||
return ret0
|
||||
}
|
||||
|
||||
// Filter indicates an expected call of Filter.
|
||||
func (mr *MockObjectDeletionStateMockRecorder) Filter(arg0 interface{}) *gomock.Call {
|
||||
// FilterJoin indicates an expected call of FilterJoin.
|
||||
func (mr *MockObjectDeletionStateMockRecorder) FilterJoin(arg0 ...interface{}) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Filter", reflect.TypeOf((*MockObjectDeletionState)(nil).Filter), arg0)
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FilterJoin", reflect.TypeOf((*MockObjectDeletionState)(nil).FilterJoin), arg0...)
|
||||
}
|
||||
|
||||
// GetQueued mocks base method.
|
||||
@@ -139,7 +145,7 @@ func (m *MockStateBuilder) EXPECT() *MockStateBuilderMockRecorder {
|
||||
}
|
||||
|
||||
// Build mocks base method.
|
||||
func (m *MockStateBuilder) Build(arg0 objecttree.ReadableObjectTree, arg1 *settingsstate.State) (*settingsstate.State, error) {
|
||||
func (m *MockStateBuilder) Build(arg0 objecttree.ObjectTree, arg1 *settingsstate.State) (*settingsstate.State, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "Build", arg0, arg1)
|
||||
ret0, _ := ret[0].(*settingsstate.State)
|
||||
|
||||
@@ -1,28 +1,7 @@
|
||||
package settingsstate
|
||||
|
||||
import "github.com/anyproto/any-sync/commonspace/spacesyncproto"
|
||||
|
||||
type State struct {
|
||||
DeletedIds map[string]struct{}
|
||||
DeletedIds []string
|
||||
DeleterId string
|
||||
LastIteratedId string
|
||||
}
|
||||
|
||||
func NewState() *State {
|
||||
return &State{DeletedIds: map[string]struct{}{}}
|
||||
}
|
||||
|
||||
func NewStateFromSnapshot(snapshot *spacesyncproto.SpaceSettingsSnapshot, lastIteratedId string) *State {
|
||||
st := NewState()
|
||||
for _, id := range snapshot.DeletedIds {
|
||||
st.DeletedIds[id] = struct{}{}
|
||||
}
|
||||
st.DeleterId = snapshot.DeleterPeerId
|
||||
st.LastIteratedId = lastIteratedId
|
||||
return st
|
||||
}
|
||||
|
||||
func (s *State) Exists(id string) bool {
|
||||
_, exists := s.DeletedIds[id]
|
||||
return exists
|
||||
}
|
||||
Loaded 100 of 173 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user