Repository navigation
Expand file tree
/
Copy pathtestwinvfs.cpp
More file actions
executable file
·797 lines (648 loc) · 39 KB
/
Copy pathtestwinvfs.cpp
File metadata and controls
executable file
·797 lines (648 loc) · 39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
/*
* This file was originally licensed under ownCloud Commercial License.
* see <https://owncloud.com/licenses/owncloud-commercial/>
* As of 2025, it is relicensed under GPL 2.0 or later.
*/
// SPDX-License-Identifier: GPL-2.0-or-later
// this include should come before every other include
#include "../src/plugins/vfs/win/cfapi_includes.h"
#include "../src/plugins/vfs/win/utility.h"
#include "../src/plugins/vfs/win/vfs_win.h"
#include "testutils/syncenginetestutils.h"
#include <syncengine.h>
#include <QtTest>
#include <chrono>
using namespace std::chrono_literals;
using namespace OCC;
SyncFileItemPtr findItem(const QSignalSpy &spy, const QString &path)
{
for (const QList<QVariant> &args : spy) {
auto item = args[0].value<SyncFileItemPtr>();
if (item->destination() == path)
return item;
}
return SyncFileItemPtr(new SyncFileItem);
}
bool itemInstruction(const QSignalSpy &spy, const QString &path, const SyncInstructions instr)
{
auto item = findItem(spy, path);
return item->instruction() == instr;
}
SyncJournalFileRecord dbRecord(FakeFolder &folder, const QString &path)
{
SyncJournalFileRecord record;
folder.syncJournal().getFileRecord(path, &record);
return record;
}
void markForDownload(FakeFolder &folder, const QByteArray &path)
{
auto &journal = folder.syncJournal();
SyncJournalFileRecord record;
journal.getFileRecord(path, &record);
if (!record.isValid())
return;
record._type = ItemTypeVirtualFileDownload;
journal.setFileRecord(record);
journal.schedulePathForRemoteDiscovery(record._path);
}
bool isPlaceholder(const QString &path)
{
auto info = CfAPIUtil::getInfo<CF_PLACEHOLDER_STANDARD_INFO>(path);
return bool(info);
}
int64_t isPlaceholderWithOnDiskSize(const QString &path)
{
auto info = CfAPIUtil::getInfo<CF_PLACEHOLDER_STANDARD_INFO>(path);
if (!info) {
return -1;
}
return info.get().OnDiskDataSize.QuadPart;
}
bool hydratePlaceholderSynchronously(const QString &path)
{
bool hydrationOk = false;
std::unique_ptr<QThread> thread(QThread::create([&]() {
auto handle = CfAPIUtil::getFileHandle(path, 0);
if (!handle)
return;
LARGE_INTEGER start;
LARGE_INTEGER end;
start.QuadPart = 0;
end.QuadPart = MAXLONGLONG;
const HRESULT ok = CfHydratePlaceholder(handle.get(), start, end, CF_HYDRATE_FLAG_NONE, nullptr);
if (FAILED(ok)) {
qWarning() << "CfHydratePlaceholder failed:" << Utility::formatWinError(ok);
hydrationOk = false;
} else {
hydrationOk = true;
}
}));
QSignalSpy spy(thread.get(), &QThread::finished);
thread->start();
OC_ENFORCE(spy.wait(std::chrono::duration_cast<std::chrono::milliseconds>(1min).count()));
return hydrationOk;
}
// Like VfsWin::setPinState but with control over recursion flag
bool setPinState(FakeFolder &folder, const QString &path, CF_PIN_STATE state, CF_SET_PIN_FLAGS flag)
{
QString fsPath = folder.localPath() + path;
auto handle = CfAPIUtil::getFileHandle(fsPath, 0);
if (!handle)
return false;
HRESULT ok = CfSetPinState(handle.get(), state, flag, nullptr);
return ok == 0;
}
class TestWinVfs : public QObject
{
Q_OBJECT
private Q_SLOTS:
void testPlaceholderCreationAndHydration()
{
FakeFolder fakeFolder { FileInfo(), Vfs::WindowsCfApi, true };
fakeFolder.account()->setCapabilities({fakeFolder.account()->url(), TestUtils::testCapabilities(CheckSums::Algorithm::SHA1)});
QSignalSpy completeSpy(&fakeFolder.syncEngine(), &SyncEngine::itemCompleted);
auto cleanup = [&]() {
completeSpy.clear();
};
cleanup();
auto someDate = QDateTime(QDate(1984, 07, 30), QTime(1,3,2));
fakeFolder.remoteModifier().mkdir(QStringLiteral("A"));
fakeFolder.remoteModifier().insert(QStringLiteral("A/a1"), 5_MiB, 'A');
fakeFolder.remoteModifier().insert(QStringLiteral("A/a2"), 5_MiB, 'A');
fakeFolder.remoteModifier().insert(QStringLiteral("A/a3"), 5_MiB, 'A');
fakeFolder.remoteModifier().insert(QStringLiteral("A/a4"), 5_MiB, 'A');
fakeFolder.remoteModifier().insert(QStringLiteral("A/a5"), 5_MiB, 'A');
fakeFolder.remoteModifier().insert(QStringLiteral("A/a6"), 0_B);
fakeFolder.remoteModifier().setModTime(QStringLiteral("A/a1"), someDate);
fakeFolder.remoteModifier().setModTime(QStringLiteral("A/a2"), someDate);
fakeFolder.remoteModifier().setModTime(QStringLiteral("A/a3"), someDate);
QString localA1 = fakeFolder.localPath() + QStringLiteral("A/a1");
QString localA2 = fakeFolder.localPath() + QStringLiteral("A/a2");
QString localA3 = fakeFolder.localPath() + QStringLiteral("A/a3");
QString localA4 = fakeFolder.localPath() + QStringLiteral("A/a4");
QString localA5 = fakeFolder.localPath() + QStringLiteral("A/a5");
QString localA6 = fakeFolder.localPath() + QStringLiteral("A/a6");
QVERIFY(fakeFolder.applyLocalModificationsAndSync());
QVERIFY(fakeFolder.vfs()->isDehydratedPlaceholder(localA1));
QCOMPARE(QFileInfo(localA1).lastModified(), someDate);
QCOMPARE(QFileInfo(localA1).size(), 5_MiB);
QVERIFY(fakeFolder.currentRemoteState().find(QStringLiteral("A/a1")));
QVERIFY(itemInstruction(completeSpy, QStringLiteral("A/a1"), CSYNC_INSTRUCTION_NEW));
QCOMPARE(dbRecord(fakeFolder, QStringLiteral("A/a1"))._type, ItemTypeVirtualFile);
QVERIFY(fakeFolder.currentLocalState().find(QStringLiteral("A/a6"))->isDehydratedPlaceholder);
// we assume further placeholders are created correctly
cleanup();
// We listen to the Vfs hydration signals to check.
//
// Check that basic hydration works
//
OperationCounter counter(fakeFolder);
QVERIFY(fakeFolder.vfs()->isDehydratedPlaceholder(localA1));
QVERIFY(hydratePlaceholderSynchronously(localA1));
QVERIFY(!fakeFolder.vfs()->isDehydratedPlaceholder(localA1));
QCOMPARE(counter.nGET, 1);
QCOMPARE(isPlaceholderWithOnDiskSize(localA1), 5_MiB);
QCOMPARE(QFileInfo(localA1).lastModified(), someDate);
QCOMPARE(QFileInfo(localA1).size(), 5_MiB);
QCOMPARE(dbRecord(fakeFolder, QStringLiteral("A/a1"))._type, ItemTypeFile);
QCOMPARE(dbRecord(fakeFolder, QStringLiteral("A/a1"))._checksumHeader, "SHA1:8886930866e6faf7558cda88305d92d13ee26cc9");
QCOMPARE(*fakeFolder.vfs()->pinState(QStringLiteral("A/a1")), PinState::Unspecified); // since it was an implicit hydration
//
// Is the remote etag propagated if it changed?
//
fakeFolder.remoteModifier().setContents(QStringLiteral("A/a2"), 5_MiB, 'M');
counter.reset();
QVERIFY(fakeFolder.vfs()->isDehydratedPlaceholder(localA2));
QVERIFY(hydratePlaceholderSynchronously(localA2));
QVERIFY(!fakeFolder.vfs()->isDehydratedPlaceholder(localA2));
QCOMPARE(counter.nGET, 1);
QCOMPARE(isPlaceholderWithOnDiskSize(localA2), 5_MiB);
QCOMPARE(QFileInfo(localA2).lastModified(), someDate);
QCOMPARE(QFileInfo(localA2).size(), 5_MiB);
QCOMPARE(dbRecord(fakeFolder, QStringLiteral("A/a2"))._type, ItemTypeFile);
QCOMPARE(dbRecord(fakeFolder, QStringLiteral("A/a2"))._etag, fakeFolder.remoteModifier().find(QStringLiteral("A/a2"))->etag);
//
// What if the remote file size changed?
//
fakeFolder.remoteModifier().appendByte(QStringLiteral("A/a3"));
counter.reset();
QVERIFY(fakeFolder.vfs()->isDehydratedPlaceholder(localA3));
QVERIFY(hydratePlaceholderSynchronously(localA3));
QVERIFY(!fakeFolder.vfs()->isDehydratedPlaceholder(localA3));
QCOMPARE(counter.nGET, 2); // the download was restarted as we detected a size missmatch between the local and the remote size
QCOMPARE(isPlaceholderWithOnDiskSize(localA3), 5_MiB + 1_B);
QCOMPARE(QFileInfo(localA3).lastModified(), someDate);
QCOMPARE(QFileInfo(localA3).size(), 5_MiB + 1_B);
QCOMPARE(dbRecord(fakeFolder, QStringLiteral("A/a3"))._type, ItemTypeFile);
QCOMPARE(dbRecord(fakeFolder, QStringLiteral("A/a3"))._etag, fakeFolder.remoteModifier().find(QStringLiteral("A/a3"))->etag);
//
// Check if a 0 (zero) byte file can be a) a placeholder before hydration,
// and b) is considered *not* to be a placeholder after hydration.
//
QVERIFY(fakeFolder.currentLocalState().find(QStringLiteral("A/a6"))->isDehydratedPlaceholder);
QVERIFY(hydratePlaceholderSynchronously(localA6));
QVERIFY(fakeFolder.currentLocalState().find(QStringLiteral("A/a6"))); // check that the file/placeholder (still) exists
QVERIFY(!fakeFolder.currentLocalState().find(QStringLiteral("A/a6"))->isDehydratedPlaceholder);
//
// Do network errors get signaled promptly?
//
fakeFolder.serverErrorPaths().append(QStringLiteral("A/a4"));
QVERIFY(!hydratePlaceholderSynchronously(localA4));
QVERIFY(fakeFolder.vfs()->isDehydratedPlaceholder(localA4));
fakeFolder.serverErrorPaths().clear();
QVERIFY(hydratePlaceholderSynchronously(localA4));
//
// Checksum validation errors are caught?
//
QByteArray checksumValue;
QObject parent;
fakeFolder.setServerOverride([&](QNetworkAccessManager::Operation op, const QNetworkRequest &request, QIODevice *) -> QNetworkReply * {
if (op == QNetworkAccessManager::GetOperation) {
auto reply = new FakeGetReply(fakeFolder.remoteModifier(), op, request, &parent);
if (!checksumValue.isNull())
reply->setRawHeader("OC-Checksum", checksumValue);
return reply;
}
return nullptr;
});
checksumValue = "SHA1:bad";
QVERIFY(!hydratePlaceholderSynchronously(localA5));
QVERIFY(fakeFolder.vfs()->isDehydratedPlaceholder(localA5));
// a second hydration attempt doesn't change anything
QVERIFY(!hydratePlaceholderSynchronously(localA5));
QVERIFY(fakeFolder.vfs()->isDehydratedPlaceholder(localA5));
checksumValue = "MD5:b8fc857a25e7958868c2f003d5e0952d";
QVERIFY(hydratePlaceholderSynchronously(localA5));
QCOMPARE(dbRecord(fakeFolder, QStringLiteral("A/a5"))._checksumHeader, "SHA1:8886930866e6faf7558cda88305d92d13ee26cc9");
fakeFolder.setServerOverride(nullptr);
// everything is hydrated and in sync
// this also checks the file contents (first byte at least)
QCOMPARE(fakeFolder.currentLocalState(), fakeFolder.currentRemoteState());
}
// Normal hydration-through-sync still works
void testSyncHydration()
{
FakeFolder fakeFolder { FileInfo(), Vfs::WindowsCfApi, true };
QSignalSpy completeSpy(&fakeFolder.syncEngine(), SIGNAL(itemCompleted(const SyncFileItemPtr &)));
auto cleanup = [&]() {
completeSpy.clear();
};
cleanup();
fakeFolder.remoteModifier().mkdir(QStringLiteral("A"));
fakeFolder.remoteModifier().insert(QStringLiteral("A/a1"), 5_MiB, 'A');
fakeFolder.remoteModifier().insert(QStringLiteral("A/a2"), 5_MiB, 'A');
QString localA1 = fakeFolder.localPath() + QStringLiteral("A/a1");
QString localA2 = fakeFolder.localPath() + QStringLiteral("A/a2");
QVERIFY(fakeFolder.applyLocalModificationsAndSync());
QVERIFY(fakeFolder.vfs()->isDehydratedPlaceholder(localA1));
QCOMPARE(dbRecord(fakeFolder, QStringLiteral("A/a1"))._type, ItemTypeVirtualFile);
cleanup();
//
// Mark for download and check it works
//
markForDownload(fakeFolder, "A/a1");
QVERIFY(fakeFolder.vfs()->setPinState(QStringLiteral("A/a2"), PinState::AlwaysLocal));
CF_FS_METADATA metadata;
QVERIFY(CfAPIUtil::getFileMetadata(fakeFolder.localPath() + QStringLiteral("A/a2"), &metadata.BasicInfo));
QVERIFY(metadata.BasicInfo.FileAttributes & FILE_ATTRIBUTE_PINNED);
QVERIFY(!(metadata.BasicInfo.FileAttributes & FILE_ATTRIBUTE_UNPINNED));
QVERIFY(fakeFolder.applyLocalModificationsAndSync());
QCOMPARE(*fakeFolder.vfs()->pinState(QStringLiteral("A/a2")), PinState::AlwaysLocal);
QCOMPARE(isPlaceholderWithOnDiskSize(localA1), 5_MiB);
QCOMPARE(dbRecord(fakeFolder, QStringLiteral("A/a1"))._type, ItemTypeFile);
QCOMPARE(isPlaceholderWithOnDiskSize(localA2), 5_MiB);
QCOMPARE(dbRecord(fakeFolder, QStringLiteral("A/a2"))._type, ItemTypeFile);
QCOMPARE(fakeFolder.currentLocalState(), fakeFolder.currentRemoteState());
QVERIFY(itemInstruction(completeSpy, QStringLiteral("A/a1"), CSYNC_INSTRUCTION_SYNC));
QVERIFY(itemInstruction(completeSpy, QStringLiteral("A/a2"), CSYNC_INSTRUCTION_SYNC));
QCOMPARE(*fakeFolder.vfs()->pinState(QStringLiteral("A/a1")), PinState::Unspecified); // since no attribute got propagated
QCOMPARE(*fakeFolder.vfs()->pinState(QStringLiteral("A/a2")), PinState::AlwaysLocal);
cleanup();
//
// If remote changes get propagated, the pin state stays unchanged
//
fakeFolder.remoteModifier().appendByte(QStringLiteral("A/a1"));
fakeFolder.remoteModifier().appendByte(QStringLiteral("A/a2"));
QVERIFY(fakeFolder.syncOnce());
QCOMPARE(*fakeFolder.vfs()->pinState(QStringLiteral("A/a1")), PinState::Unspecified); // since no attribute got propagated
QCOMPARE(*fakeFolder.vfs()->pinState(QStringLiteral("A/a2")), PinState::AlwaysLocal);
cleanup();
}
// Placeholder moving and deleting gets propagated
void testMoveDelete()
{
FakeFolder fakeFolder { FileInfo(), Vfs::WindowsCfApi, true };
QSignalSpy completeSpy(&fakeFolder.syncEngine(), SIGNAL(itemCompleted(const SyncFileItemPtr &)));
auto cleanup = [&]() {
completeSpy.clear();
};
cleanup();
auto l = [&](const QString &p) { return QString(fakeFolder.localPath() + p); };
fakeFolder.remoteModifier().mkdir(QStringLiteral("A"));
fakeFolder.remoteModifier().insert(QStringLiteral("A/a1"), 5_MiB, 'A');
fakeFolder.remoteModifier().insert(QStringLiteral("A/b1"), 5_MiB, 'A');
fakeFolder.remoteModifier().insert(QStringLiteral("f1"), 5_MiB, 'A');
fakeFolder.remoteModifier().insert(QStringLiteral("q1"), 5_MiB, 'A');
fakeFolder.remoteModifier().insert(QStringLiteral("A/d1"), 5_MiB, 'A');
fakeFolder.remoteModifier().insert(QStringLiteral("A/d2"), 5_MiB, 'A');
QVERIFY(fakeFolder.syncOnce());
cleanup();
fakeFolder.localModifier().rename(QStringLiteral("f1"), QStringLiteral("f2"));
fakeFolder.localModifier().rename(QStringLiteral("A/a1"), QStringLiteral("a1"));
fakeFolder.localModifier().remove(QStringLiteral("A/d1"));
fakeFolder.remoteModifier().rename(QStringLiteral("q1"), QStringLiteral("q2"));
fakeFolder.remoteModifier().rename(QStringLiteral("A/b1"), QStringLiteral("b1"));
fakeFolder.remoteModifier().remove(QStringLiteral("A/d2"));
QVERIFY(fakeFolder.applyLocalModificationsAndSync());
QVERIFY(itemInstruction(completeSpy, QStringLiteral("f2"), CSYNC_INSTRUCTION_RENAME));
QVERIFY(itemInstruction(completeSpy, QStringLiteral("a1"), CSYNC_INSTRUCTION_RENAME));
QVERIFY(itemInstruction(completeSpy, QStringLiteral("q2"), CSYNC_INSTRUCTION_RENAME));
QVERIFY(itemInstruction(completeSpy, QStringLiteral("b1"), CSYNC_INSTRUCTION_RENAME));
QVERIFY(itemInstruction(completeSpy, QStringLiteral("A/d1"), CSYNC_INSTRUCTION_REMOVE));
QVERIFY(itemInstruction(completeSpy, QStringLiteral("A/d2"), CSYNC_INSTRUCTION_REMOVE));
QVERIFY(fakeFolder.vfs()->isDehydratedPlaceholder(l(QStringLiteral("f2"))));
QVERIFY(fakeFolder.vfs()->isDehydratedPlaceholder(l(QStringLiteral("a1"))));
QVERIFY(fakeFolder.vfs()->isDehydratedPlaceholder(l(QStringLiteral("q2"))));
QVERIFY(fakeFolder.vfs()->isDehydratedPlaceholder(l(QStringLiteral("b1"))));
QVERIFY(!fakeFolder.vfs()->isDehydratedPlaceholder(l(QStringLiteral("A/d1"))));
QVERIFY(!fakeFolder.vfs()->isDehydratedPlaceholder(l(QStringLiteral("A/d2"))));
QCOMPARE(dbRecord(fakeFolder, QStringLiteral("f2"))._type, ItemTypeVirtualFile);
QCOMPARE(dbRecord(fakeFolder, QStringLiteral("a1"))._type, ItemTypeVirtualFile);
QCOMPARE(dbRecord(fakeFolder, QStringLiteral("q2"))._type, ItemTypeVirtualFile);
QCOMPARE(dbRecord(fakeFolder, QStringLiteral("b1"))._type, ItemTypeVirtualFile);
QVERIFY(!dbRecord(fakeFolder, QStringLiteral("A/d1")).isValid());
QVERIFY(!dbRecord(fakeFolder, QStringLiteral("A/d2")).isValid());
QVERIFY(fakeFolder.currentRemoteState().find(QStringLiteral("f2")));
QVERIFY(fakeFolder.currentRemoteState().find(QStringLiteral("a1")));
QVERIFY(!fakeFolder.currentRemoteState().find(QStringLiteral("A/d1")));
cleanup();
}
// Placeholders update size/mtime if remote metadata changes
void testMetadataUpdate()
{
FakeFolder fakeFolder { FileInfo(), Vfs::WindowsCfApi, true };
QSignalSpy completeSpy(&fakeFolder.syncEngine(), SIGNAL(itemCompleted(const SyncFileItemPtr &)));
auto cleanup = [&]() {
completeSpy.clear();
};
cleanup();
auto l = [&](const QString &p) { return QString(fakeFolder.localPath() + p); };
auto someDate = QDateTime(QDate(1984, 07, 30), QTime(1,3,2));
fakeFolder.remoteModifier().mkdir(QStringLiteral("A"));
fakeFolder.remoteModifier().insert(QStringLiteral("A/a1"), 5_MiB, 'A');
fakeFolder.remoteModifier().setModTime(QStringLiteral("A/a1"), someDate);
QVERIFY(fakeFolder.syncOnce());
QVERIFY(itemInstruction(completeSpy, QStringLiteral("A/a1"), CSYNC_INSTRUCTION_NEW));
QVERIFY(fakeFolder.vfs()->isDehydratedPlaceholder(l(QStringLiteral("A/a1"))));
QCOMPARE(QFileInfo(l(QStringLiteral("A/a1"))).size(), 5_MiB);
QCOMPARE(QFileInfo(l(QStringLiteral("A/a1"))).lastModified(), someDate);
cleanup();
// Change the remote metadata and check whether it propagates
auto otherDate = QDateTime(QDate(2000, 03, 03), QTime(2,5,4));
fakeFolder.remoteModifier().appendByte(QStringLiteral("A/a1"));
fakeFolder.remoteModifier().setModTime(QStringLiteral("A/a1"), otherDate);
QVERIFY(fakeFolder.syncOnce());
QVERIFY(itemInstruction(completeSpy, QStringLiteral("A/a1"), CSYNC_INSTRUCTION_UPDATE_METADATA));
QVERIFY(fakeFolder.vfs()->isDehydratedPlaceholder(l(QStringLiteral("A/a1"))));
QCOMPARE(QFileInfo(l(QStringLiteral("A/a1"))).size(), 5_MiB + 1_B);
QCOMPARE(QFileInfo(l(QStringLiteral("A/a1"))).lastModified(), otherDate);
cleanup();
// No spurious sync
QVERIFY(fakeFolder.syncOnce());
QVERIFY(completeSpy.isEmpty());
cleanup();
}
// Various kinds of conflicts
void testConflicts()
{
FakeFolder fakeFolder { FileInfo(), Vfs::WindowsCfApi, true };
QSignalSpy completeSpy(&fakeFolder.syncEngine(), SIGNAL(itemCompleted(const SyncFileItemPtr &)));
auto cleanup = [&]() {
completeSpy.clear();
};
cleanup();
auto l = [&](const QString &p) { return QString(fakeFolder.localPath() + p); };
fakeFolder.remoteModifier().mkdir(QStringLiteral("A"));
fakeFolder.remoteModifier().insert(QStringLiteral("A/localdelete"), 5_MiB, 'A');
fakeFolder.remoteModifier().insert(QStringLiteral("A/localreplace1"), 5_MiB, 'A');
fakeFolder.remoteModifier().insert(QStringLiteral("A/localreplace2"), 5_MiB, 'A');
fakeFolder.remoteModifier().insert(QStringLiteral("A/localreplace3"), 5_MiB, 'A');
fakeFolder.remoteModifier().insert(QStringLiteral("A/localreplace4"), 5_MiB, 'A');
QVERIFY(fakeFolder.syncOnce());
QVERIFY(fakeFolder.vfs()->isDehydratedPlaceholder(l(QStringLiteral("A/localdelete"))));
cleanup();
// Now try remote/local conflicts
fakeFolder.remoteModifier().appendByte(QStringLiteral("A/localdelete"));
// localreplace1/2 aren't actual conflicts, but switch out the placeholder in an
// interesting way
fakeFolder.remoteModifier().appendByte(QStringLiteral("A/localreplace3"));
fakeFolder.remoteModifier().appendByte(QStringLiteral("A/localreplace4"));
fakeFolder.localModifier().remove(QStringLiteral("A/localdelete"));
fakeFolder.localModifier().remove(QStringLiteral("A/localreplace1"));
fakeFolder.localModifier().remove(QStringLiteral("A/localreplace2"));
fakeFolder.localModifier().remove(QStringLiteral("A/localreplace3"));
fakeFolder.localModifier().remove(QStringLiteral("A/localreplace4"));
fakeFolder.localModifier().insert(QStringLiteral("A/localreplace1"), 1_MiB, 'B');
fakeFolder.localModifier().insert(QStringLiteral("A/localreplace2"), 5_MiB, 'A');
fakeFolder.localModifier().insert(QStringLiteral("A/localreplace3"), 1_MiB, 'B');
fakeFolder.localModifier().insert(QStringLiteral("A/localreplace4"), 5_MiB, 'A');
QVERIFY(fakeFolder.applyLocalModificationsAndSync());
QVERIFY(itemInstruction(completeSpy, QStringLiteral("A/localdelete"), CSYNC_INSTRUCTION_NEW));
QVERIFY(fakeFolder.vfs()->isDehydratedPlaceholder(l(QStringLiteral("A/localdelete"))));
QCOMPARE(QFileInfo(l(QStringLiteral("A/localdelete"))).size(), 5_MiB + 1_B);
QVERIFY(itemInstruction(completeSpy, QStringLiteral("A/localreplace1"), CSYNC_INSTRUCTION_SYNC));
// isn't a placeholder at all
QVERIFY(itemInstruction(completeSpy, QStringLiteral("A/localreplace2"), CSYNC_INSTRUCTION_SYNC)); // no sync?
// isn't a placeholder at all
QVERIFY(itemInstruction(completeSpy, QStringLiteral("A/localreplace3"), CSYNC_INSTRUCTION_CONFLICT));
QVERIFY(itemInstruction(completeSpy, QStringLiteral("A/localreplace4"), CSYNC_INSTRUCTION_CONFLICT));
cleanup();
}
// Check what happens if there's a rename and a pin/hydration change
// Check SyncVirtualFiles::testRenameVirtual2 which does the same for suffix vfs
void testRenameVirtual2()
{
FakeFolder fakeFolder { FileInfo(), Vfs::WindowsCfApi, true };
auto l = [&](const QString &p) { return QString(fakeFolder.localPath() + p); };
QSignalSpy completeSpy(&fakeFolder.syncEngine(), SIGNAL(itemCompleted(const SyncFileItemPtr &)));
auto cleanup = [&]() {
completeSpy.clear();
};
cleanup();
fakeFolder.remoteModifier().insert(QStringLiteral("case3"), 128_B, 'C');
fakeFolder.remoteModifier().insert(QStringLiteral("case4"), 256_B, 'C');
fakeFolder.remoteModifier().insert(QStringLiteral("case5"), 256_B, 'C');
fakeFolder.remoteModifier().insert(QStringLiteral("case6"), 256_B, 'C');
QVERIFY(fakeFolder.applyLocalModificationsAndSync());
QVERIFY(fakeFolder.vfs()->setPinState(QStringLiteral("case4"), PinState::AlwaysLocal));
QVERIFY(fakeFolder.vfs()->setPinState(QStringLiteral("case6"), PinState::AlwaysLocal));
QVERIFY(fakeFolder.applyLocalModificationsAndSync());
QVERIFY(fakeFolder.vfs()->isDehydratedPlaceholder(l(QStringLiteral("case3"))));
QCOMPARE(isPlaceholderWithOnDiskSize(l(QStringLiteral("case4"))), 256);
QVERIFY(fakeFolder.vfs()->isDehydratedPlaceholder(l(QStringLiteral("case5"))));
cleanup();
// Case 1: foo -> bar (tested elsewhere)
// Case 2: foo.oc -> bar.oc (tested elsewhere)
// Case 3: foo -> bar (foo starts dehydrated, pin state changed to alwayslocal)
fakeFolder.localModifier().rename(QStringLiteral("case3"), QStringLiteral("case3-rename"));
QVERIFY(fakeFolder.applyLocalModificationsWithoutSync());
QVERIFY(fakeFolder.vfs()->setPinState(QStringLiteral("case3-rename"), PinState::AlwaysLocal));
// Case 4: foo -> bar (foo starts hydrated, pin state changed to onlineonly)
fakeFolder.localModifier().rename(QStringLiteral("case4"), QStringLiteral("case4-rename"));
QVERIFY(fakeFolder.applyLocalModificationsWithoutSync());
QVERIFY(fakeFolder.vfs()->setPinState(QStringLiteral("case4-rename"), PinState::OnlineOnly));
// Case 5: foo -> bar (foo starts dehydrated, db changed to ITVFDownload)
fakeFolder.localModifier().rename(QStringLiteral("case5"), QStringLiteral("case5-rename"));
markForDownload(fakeFolder, "case5");
QVERIFY(fakeFolder.applyLocalModificationsAndSync());
// Case 3: the rename went though, pin state change still on file
QVERIFY(!fakeFolder.currentLocalState().find(QStringLiteral("case3")));
QVERIFY(fakeFolder.vfs()->isDehydratedPlaceholder(l(QStringLiteral("case3-rename"))));
QVERIFY(!fakeFolder.currentRemoteState().find(QStringLiteral("case3")));
QVERIFY(fakeFolder.currentRemoteState().find(QStringLiteral("case3-rename")));
QVERIFY(itemInstruction(completeSpy, QStringLiteral("case3-rename"), CSYNC_INSTRUCTION_RENAME));
QCOMPARE(dbRecord(fakeFolder, QStringLiteral("case3-rename"))._type, ItemTypeVirtualFile);
QCOMPARE(*fakeFolder.vfs()->pinState(QStringLiteral("case3-rename")), PinState::AlwaysLocal);
// Case 4: the rename went though, pin state change still on file
QVERIFY(!fakeFolder.currentLocalState().find(QStringLiteral("case4")));
QVERIFY(fakeFolder.currentLocalState().find(QStringLiteral("case4-rename")));
QCOMPARE(isPlaceholderWithOnDiskSize(l(QStringLiteral("case4-rename"))), 256);
QVERIFY(!fakeFolder.currentRemoteState().find(QStringLiteral("case4")));
QVERIFY(fakeFolder.currentRemoteState().find(QStringLiteral("case4-rename")));
QVERIFY(itemInstruction(completeSpy, QStringLiteral("case4-rename"), CSYNC_INSTRUCTION_RENAME));
QCOMPARE(dbRecord(fakeFolder, QStringLiteral("case4-rename"))._type, ItemTypeFile);
QCOMPARE(*fakeFolder.vfs()->pinState(QStringLiteral("case4-rename")), PinState::OnlineOnly);
// at this point it'd be nice if the client had anotherSyncNeeded set, to
// make sure the pin state change gets applied!
// Case 5: the rename went though, hydration is forgotten
QVERIFY(!fakeFolder.currentLocalState().find(QStringLiteral("case5")));
QVERIFY(fakeFolder.vfs()->isDehydratedPlaceholder(l(QStringLiteral("case5-rename"))));
QVERIFY(!fakeFolder.currentRemoteState().find(QStringLiteral("case5")));
QVERIFY(fakeFolder.currentRemoteState().find(QStringLiteral("case5-rename")));
QVERIFY(itemInstruction(completeSpy, QStringLiteral("case5-rename"), CSYNC_INSTRUCTION_RENAME));
QVERIFY(dbRecord(fakeFolder, QStringLiteral("case5-rename"))._type == ItemTypeVirtualFile);
}
// Dehydration via sync works, when going through file attributes
void testSyncDehydrationViaUnpin()
{
FakeFolder fakeFolder { FileInfo::A12_B12_C12_S12(), Vfs::WindowsCfApi };
auto l = [&](const QString &p) { return QString(fakeFolder.localPath() + p); };
QVERIFY(fakeFolder.applyLocalModificationsAndSync());
QCOMPARE(fakeFolder.currentLocalState(), fakeFolder.currentRemoteState());
QSignalSpy completeSpy(&fakeFolder.syncEngine(), SIGNAL(itemCompleted(const SyncFileItemPtr &)));
auto cleanup = [&]() {
completeSpy.clear();
};
cleanup();
//
// Mark for dehydration and check
//
QVERIFY(fakeFolder.vfs()->setPinState(QStringLiteral("A/a1"), PinState::OnlineOnly));
QVERIFY(fakeFolder.vfs()->setPinState(QStringLiteral("A/a2"), PinState::OnlineOnly));
fakeFolder.remoteModifier().appendByte(QStringLiteral("A/a2"));
// expect: normal dehydration
QVERIFY(fakeFolder.vfs()->setPinState(QStringLiteral("B/b1"), PinState::OnlineOnly));
fakeFolder.remoteModifier().remove(QStringLiteral("B/b1"));
// expect: local removal
QVERIFY(fakeFolder.vfs()->setPinState(QStringLiteral("B/b2"), PinState::OnlineOnly));
fakeFolder.remoteModifier().rename(QStringLiteral("B/b2"), QStringLiteral("B/b3"));
// expect: B/b2 is renamed to B/b3, later maybe dehydration?
QVERIFY(fakeFolder.vfs()->setPinState(QStringLiteral("C/c1"), PinState::OnlineOnly));
fakeFolder.localModifier().appendByte(QStringLiteral("C/c1"));
// expect: no dehydration, upload of c1
QVERIFY(fakeFolder.vfs()->setPinState(QStringLiteral("C/c2"), PinState::OnlineOnly));
fakeFolder.localModifier().appendByte(QStringLiteral("C/c2"));
fakeFolder.remoteModifier().appendByte(QStringLiteral("C/c2"));
fakeFolder.remoteModifier().appendByte(QStringLiteral("C/c2"));
// expect: no dehydration, conflict
// A new not-in-db file that's nevertheless unpinned
fakeFolder.localModifier().insert(QStringLiteral("C/n"));
QVERIFY(fakeFolder.applyLocalModificationsWithoutSync());
QVERIFY(fakeFolder.vfs()->setPinState(QStringLiteral("C/n"), PinState::OnlineOnly));
// expect: uploaded, later maybe dehydration?
QVERIFY(fakeFolder.applyLocalModificationsAndSync());
QVERIFY(fakeFolder.vfs()->isDehydratedPlaceholder(l(QStringLiteral("A/a1"))));
QVERIFY(fakeFolder.vfs()->isDehydratedPlaceholder(l(QStringLiteral("A/a2"))));
QVERIFY(!fakeFolder.currentLocalState().find(QStringLiteral("B/b1")));
QVERIFY(!fakeFolder.currentRemoteState().find(QStringLiteral("B/b1")));
QVERIFY(itemInstruction(completeSpy, QStringLiteral("B/b1"), CSYNC_INSTRUCTION_REMOVE));
QVERIFY(!fakeFolder.currentLocalState().find(QStringLiteral("B/b2")));
QVERIFY(!fakeFolder.currentRemoteState().find(QStringLiteral("B/b2")));
QVERIFY(!fakeFolder.vfs()->isDehydratedPlaceholder(l(QStringLiteral("B/b3")))); // because the non-virtual was renamed
QVERIFY(itemInstruction(completeSpy, QStringLiteral("B/b3"), CSYNC_INSTRUCTION_RENAME));
// TODO: b3 still has the UNPINNED state?
QCOMPARE(isPlaceholderWithOnDiskSize(l(QStringLiteral("C/c1"))), 25);
QCOMPARE(fakeFolder.currentRemoteState().find(QStringLiteral("C/c1"))->contentSize, 25);
QVERIFY(itemInstruction(completeSpy, QStringLiteral("C/c1"), CSYNC_INSTRUCTION_SYNC));
QCOMPARE(isPlaceholderWithOnDiskSize(l(QStringLiteral("C/c2"))), 26);
QCOMPARE(fakeFolder.currentRemoteState().find(QStringLiteral("C/c2"))->contentSize, 26);
QVERIFY(itemInstruction(completeSpy, QStringLiteral("C/c2"), CSYNC_INSTRUCTION_CONFLICT));
QCOMPARE(isPlaceholderWithOnDiskSize(l(QStringLiteral("C/n"))), 64);
QCOMPARE(fakeFolder.currentRemoteState().find(QStringLiteral("C/n"))->contentSize, 64);
QVERIFY(itemInstruction(completeSpy, QStringLiteral("C/n"), CSYNC_INSTRUCTION_NEW));
// TODO: n still has UNPINNED state?
cleanup();
}
void testWipePlaceholders()
{
FakeFolder fakeFolder { FileInfo(), Vfs::WindowsCfApi, true };
auto l = [&](const QString &p) { return QString(fakeFolder.localPath() + p); };
// Create a baseline
fakeFolder.remoteModifier().mkdir(QStringLiteral("A"));
fakeFolder.remoteModifier().mkdir(QStringLiteral("A/B"));
fakeFolder.remoteModifier().insert(QStringLiteral("f1"));
fakeFolder.remoteModifier().insert(QStringLiteral("A/a1"));
fakeFolder.remoteModifier().insert(QStringLiteral("A/a3"));
fakeFolder.remoteModifier().insert(QStringLiteral("A/B/b1"));
fakeFolder.localModifier().mkdir(QStringLiteral("A"));
fakeFolder.localModifier().mkdir(QStringLiteral("A/B"));
fakeFolder.localModifier().insert(QStringLiteral("f2"));
fakeFolder.localModifier().insert(QStringLiteral("A/a2"));
fakeFolder.localModifier().insert(QStringLiteral("A/B/b2"));
QVERIFY(fakeFolder.applyLocalModificationsAndSync());
QVERIFY(fakeFolder.vfs()->isDehydratedPlaceholder(l(QStringLiteral("f1"))));
QVERIFY(fakeFolder.vfs()->isDehydratedPlaceholder(l(QStringLiteral("A/a1"))));
QVERIFY(fakeFolder.vfs()->isDehydratedPlaceholder(l(QStringLiteral("A/a3"))));
QVERIFY(fakeFolder.vfs()->isDehydratedPlaceholder(l(QStringLiteral("A/B/b1"))));
// Make local changes to a3
fakeFolder.localModifier().remove(QStringLiteral("A/a3"));
fakeFolder.localModifier().insert(QStringLiteral("A/a3"), 100_B);
QVERIFY(fakeFolder.applyLocalModificationsWithoutSync());
fakeFolder.vfs()->wipeDehydratedVirtualFiles();
fakeFolder.vfs()->stop();
fakeFolder.vfs()->unregisterFolder();
QVERIFY(!QFile::exists(l(QStringLiteral("f1"))));
QVERIFY(!QFile::exists(l(QStringLiteral("A/a1"))));
QVERIFY(QFile::exists(l(QStringLiteral("A/a3"))));
QVERIFY(!QFile::exists(l(QStringLiteral("A/B/b1"))));
// Check that syncing with vfs disabled is fine
auto vfsOff = QSharedPointer<Vfs>(VfsPluginManager::instance().createVfsFromPlugin(Vfs::Off).release());
QVERIFY(vfsOff);
fakeFolder.switchToVfs(vfsOff);
QVERIFY(fakeFolder.applyLocalModificationsAndSync());
auto conflicts = fakeFolder.syncJournal().conflictRecordPaths();
QCOMPARE(conflicts.size(), 1);
QFile::remove(l(QString::fromUtf8(conflicts[0])));
QCOMPARE(fakeFolder.currentLocalState(), fakeFolder.currentRemoteState());
}
void testAvailability()
{
FakeFolder fakeFolder { FileInfo(), Vfs::WindowsCfApi, true };
fakeFolder.remoteModifier().mkdir(QStringLiteral("A"));
fakeFolder.remoteModifier().insert(QStringLiteral("A/a1"));
fakeFolder.remoteModifier().insert(QStringLiteral("A/a2"));
fakeFolder.syncOnce();
QCOMPARE(*fakeFolder.vfs()->availability(QString()), VfsItemAvailability::AllDehydrated);
QCOMPARE(*fakeFolder.vfs()->availability(QStringLiteral("A")), VfsItemAvailability::AllDehydrated);
QCOMPARE(*fakeFolder.vfs()->availability(QStringLiteral("A/a1")), VfsItemAvailability::AllDehydrated);
// The Vfs property is only accessible when it's not "sync pending"
auto updateSyncState = [&] {
fakeFolder.vfs()->fileStatusChanged(fakeFolder.localPath() + QStringLiteral("A/a1"), SyncFileStatus(SyncFileStatus::StatusUpToDate));
fakeFolder.vfs()->fileStatusChanged(fakeFolder.localPath() + QStringLiteral("A/a2"), SyncFileStatus(SyncFileStatus::StatusUpToDate));
fakeFolder.vfs()->fileStatusChanged(fakeFolder.localPath() + QStringLiteral("A"), SyncFileStatus(SyncFileStatus::StatusUpToDate));
};
QVERIFY(fakeFolder.vfs()->setPinState(QStringLiteral("A"), PinState::AlwaysLocal));
fakeFolder.syncOnce();
updateSyncState();
QCOMPARE(*fakeFolder.vfs()->availability(QString()), VfsItemAvailability::AllHydrated);
QCOMPARE(*fakeFolder.vfs()->availability(QStringLiteral("A")), VfsItemAvailability::AlwaysLocal);
QCOMPARE(*fakeFolder.vfs()->availability(QStringLiteral("A/a1")), VfsItemAvailability::AlwaysLocal);
QVERIFY(fakeFolder.vfs()->setPinState(QStringLiteral("A/a1"), PinState::Unspecified));
fakeFolder.syncOnce();
updateSyncState();
QCOMPARE(*fakeFolder.vfs()->availability(QString()), VfsItemAvailability::AllHydrated);
QCOMPARE(*fakeFolder.vfs()->availability(QStringLiteral("A")), VfsItemAvailability::AllHydrated);
QCOMPARE(*fakeFolder.vfs()->availability(QStringLiteral("A/a1")), VfsItemAvailability::AllHydrated);
QCOMPARE(*fakeFolder.vfs()->availability(QStringLiteral("A/a2")), VfsItemAvailability::AlwaysLocal);
QVERIFY(fakeFolder.vfs()->setPinState(QStringLiteral("A"), PinState::OnlineOnly));
fakeFolder.syncOnce();
updateSyncState();
QCOMPARE(*fakeFolder.vfs()->availability(QString()), VfsItemAvailability::AllDehydrated);
QCOMPARE(*fakeFolder.vfs()->availability(QStringLiteral("A")), VfsItemAvailability::AllDehydrated);
QCOMPARE(*fakeFolder.vfs()->availability(QStringLiteral("A/a1")), VfsItemAvailability::AllDehydrated);
QVERIFY(fakeFolder.vfs()->setPinState(QStringLiteral("A/a1"), PinState::AlwaysLocal));
fakeFolder.syncOnce();
updateSyncState();
QCOMPARE(*fakeFolder.vfs()->availability(QString()), VfsItemAvailability::Mixed);
QCOMPARE(*fakeFolder.vfs()->availability(QStringLiteral("A")), VfsItemAvailability::Mixed);
QCOMPARE(*fakeFolder.vfs()->availability(QStringLiteral("A/a1")), VfsItemAvailability::AlwaysLocal);
}
// Check that previously hydrated files become placeholders on sync
void testConvertToPlaceholders()
{
FakeFolder fakeFolder { FileInfo {}, Vfs::Off };
fakeFolder.remoteModifier().mkdir(QStringLiteral("A"));
fakeFolder.remoteModifier().insert(QStringLiteral("A/a1"), 64_B);
QVERIFY(fakeFolder.applyLocalModificationsAndSync());
fakeFolder.switchToVfs(QSharedPointer<Vfs>(new VfsWin));
QSignalSpy completeSpy(&fakeFolder.syncEngine(), SIGNAL(itemCompleted(const SyncFileItemPtr &)));
QVERIFY(fakeFolder.applyLocalModificationsAndSync());
QVERIFY(itemInstruction(completeSpy, QStringLiteral("A/a1"), CSYNC_INSTRUCTION_UPDATE_METADATA));
QCOMPARE(isPlaceholderWithOnDiskSize(QString(fakeFolder.localPath() + QStringLiteral("A/a1"))), 64_B);
completeSpy.clear();
QVERIFY(fakeFolder.applyLocalModificationsAndSync());
QVERIFY(itemInstruction(completeSpy, QStringLiteral("A/a1"), CSYNC_INSTRUCTION_NONE));
QCOMPARE(isPlaceholderWithOnDiskSize(QString(fakeFolder.localPath() + QStringLiteral("A/a1"))), 64_B);
}
void testIsPlaceholder()
{
FakeFolder fakeFolder = { FileInfo {}, Vfs::WindowsCfApi };
fakeFolder.remoteModifier().mkdir(QStringLiteral("A"));
fakeFolder.remoteModifier().insert(QStringLiteral("A/zeroBytesHydrated"), 0_B);
fakeFolder.remoteModifier().insert(QStringLiteral("A/zeroBytesDeHydrated"), 0_B);
fakeFolder.remoteModifier().insert(QStringLiteral("A/Hydrated"));
fakeFolder.remoteModifier().insert(QStringLiteral("A/DeHydrated"));
QVERIFY(fakeFolder.applyLocalModificationsAndSync());
QVERIFY(fakeFolder.vfs()->setPinState(QStringLiteral("A/zeroBytesHydrated"), PinState::AlwaysLocal));
QVERIFY(fakeFolder.vfs()->setPinState(QStringLiteral("A/zeroBytesDeHydrated"), PinState::OnlineOnly));
QVERIFY(fakeFolder.vfs()->setPinState(QStringLiteral("A/Hydrated"), PinState::AlwaysLocal));
QVERIFY(fakeFolder.vfs()->setPinState(QStringLiteral("A/DeHydrated"), PinState::OnlineOnly));
QVERIFY(fakeFolder.syncOnce());
QVERIFY(!fakeFolder.vfs()->isDehydratedPlaceholder(fakeFolder.localPath() + QStringLiteral("A/zeroBytesHydrated")));
QVERIFY(fakeFolder.vfs()->isDehydratedPlaceholder(fakeFolder.localPath() + QStringLiteral("A/zeroBytesDeHydrated")));
QVERIFY(!fakeFolder.vfs()->isDehydratedPlaceholder(fakeFolder.localPath() + QStringLiteral("A/Hydrated")));
QVERIFY(fakeFolder.vfs()->isDehydratedPlaceholder(fakeFolder.localPath() + QStringLiteral("A/DeHydrated")));
}
};
QTEST_GUILESS_MAIN(TestWinVfs)
#include "testwinvfs.moc"