Repository navigation
Expand file tree
/
Copy pathtest_app.cpp
More file actions
7518 lines (6453 loc) · 349 KB
/
Copy pathtest_app.cpp
File metadata and controls
7518 lines (6453 loc) · 349 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
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// This file is part of the Diffractor photo and video organizer
// Copyright 2026 Zac Walker
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
// Purpose: Tests for application coordination (app*, view_* task views): command registration, what
// each view declares for the frame's bars and how a bar is arranged, input dispatch, settings
// persistence and the Options view that edits them, headless Movie batches, and rename, import, sync and
// convert planning.
#include "pch.h"
#include "files.h"
#include "test.h"
#include "model_db.h"
#include "model_index.h"
#include "test_fixtures.h"
#include "test_runner.h"
#include "util_crash_files_db.h"
#include "util_zip.h"
#include "app_command_line.h"
#include "app_util.h"
#include "app_settings.h"
#include "app_text.h"
#include "app_commands.h"
#include "app_search.h"
#include "ui_dialog.h"
#include "app.h"
#include "app_sidebar.h"
#include "app_dialogs.h"
#include "av_format.h"
#include "view_movie.h"
#include "view_rename.h"
#include "view_batch.h"
#include "view_import.h"
#include "view_sync.h"
#include "view_tags.h"
#include "view_items.h"
#include "view_media.h"
#include "view_options.h"
#include "libdesktop/ui/test_support.h"
extern std::function<void()> test_during_detach_file_handles;
// Rolling a release back is ordinary, and the settings store is shared with the build rolled back
// to. An order it cannot name falls through its switches to a default, so the user silently loses
// the order they chose - which is exactly the user this release's migration just moved onto one.
static void should_store_an_order_an_older_build_can_read()
{
const auto plain = [](const group_by o)
{
return static_cast<uint32_t>(group_order_older_builds_understand(o));
};
const auto ex = [](const group_by o)
{
return static_cast<uint32_t>(o);
};
// Every order an older build already knows is stored unchanged.
for (const auto order : {group_by::file_type, group_by::size, group_by::date_created, group_by::date_modified,
group_by::camera, group_by::folder})
{
assert_equal(static_cast<int>(order), static_cast<int>(group_order_older_builds_understand(order)),
"a known order is stored as itself");
}
// The one it does not is stood in for by the order that meant the same thing to it.
assert_equal(static_cast<int>(group_by::date_created),
static_cast<int>(group_order_older_builds_understand(group_by::date_original)),
"Original stands in as date created");
assert_equal(static_cast<int>(sort_by::date_created),
static_cast<int>(sort_order_older_builds_understand(sort_by::date_original)),
"and the same for sorting");
// A round trip through both keys returns the real order, stand-in or not.
assert_equal(static_cast<int>(group_by::date_original),
static_cast<int>(resolve_stored_order<group_by>(plain(group_by::date_original),
ex(group_by::date_original), true,
group_order_older_builds_understand)),
"the true order survives its own stand-in");
assert_equal(static_cast<int>(group_by::camera),
static_cast<int>(resolve_stored_order<group_by>(plain(group_by::camera), ex(group_by::camera), true,
group_order_older_builds_understand)),
"and so does an order needing none");
// An older build knows only the plain key. When it has written one, that is the newer choice and
// the stale extended value must not overrule it.
assert_equal(static_cast<int>(group_by::camera),
static_cast<int>(resolve_stored_order<group_by>(static_cast<uint32_t>(group_by::camera),
ex(group_by::date_original), true,
group_order_older_builds_understand)),
"a choice made in the older build wins");
// Upgrading for the first time: only the plain key exists.
assert_equal(static_cast<int>(group_by::date_created),
static_cast<int>(resolve_stored_order<group_by>(static_cast<uint32_t>(group_by::date_created), 0,
false, group_order_older_builds_understand)),
"a store with no extended key answers with what it has");
}
static void should_bound_advanced_search_hover_thumbnail_retries()
{
auto retries = 2;
assert_equal(true, should_refresh_advanced_search_hover_thumbnail(false, true, false, retries),
"first failed thumbnail hover is retried");
assert_equal(1, retries, "retry budget decrements");
assert_equal(true, should_refresh_advanced_search_hover_thumbnail(false, true, true, retries),
"in-flight staging keeps the hover refreshing without spending the budget");
assert_equal(1, retries, "in-flight refresh does not spend retry budget");
assert_equal(true, should_refresh_advanced_search_hover_thumbnail(false, true, false, retries),
"second failed thumbnail hover is retried");
assert_equal(0, retries, "retry budget reaches zero");
assert_equal(false, should_refresh_advanced_search_hover_thumbnail(false, true, false, retries),
"exhausted thumbnail retries stop refreshing");
assert_equal(false, should_refresh_advanced_search_hover_thumbnail(true, true, false, retries),
"an available surface needs no refresh");
}
static void should_persist_to_ini_file()
{
const auto settings_folder = test_temps.folder().combine("ini-settings");
platform::create_folder(settings_folder);
const auto settings = platform::create_ini_file_settings(settings_folder);
// A folder without an INI is a new settings root.
assert_equal(true, settings->root_created(), "root_created", "INI file settings");
// Test uint32_t
constexpr uint32_t test_uint32 = 12345;
settings->write("test_section", "uint32_value", test_uint32);
const auto existing_settings = platform::create_ini_file_settings(settings_folder);
assert_equal(false, existing_settings->root_created(), "existing root", "INI file settings");
uint32_t read_uint32 = 0;
assert_equal(true, settings->read("test_section", "uint32_value", read_uint32), "read uint32", "INI file settings");
assert_equal(test_uint32, read_uint32, "uint32 value", "INI file settings");
// Test uint64_t
constexpr uint64_t test_uint64 = 0xFFFFFFFFFFFFull;
settings->write("test_section", "uint64_value", test_uint64);
uint64_t read_uint64 = 0;
assert_equal(true, settings->read("test_section", "uint64_value", read_uint64), "read uint64", "INI file settings");
assert_equal(test_uint64, read_uint64, "uint64 value", "INI file settings");
// Test string
const auto test_string = "Hello, World! With special chars: äöü"s;
settings->write("test_section", "string_value", test_string);
std::string read_string;
assert_equal(true, settings->read("test_section", "string_value", read_string), "read string", "INI file settings");
assert_equal(test_string, read_string, "string value", "INI file settings");
for (const auto value : {"\"folder with spaces\" \"photo.jpg\""sv, "'quoted tag'"sv})
{
settings->write("test_section", "literal_value", value);
const auto reopened = platform::create_ini_file_settings(settings_folder);
std::string read_literal;
assert_equal(true, reopened->read("test_section", "literal_value", read_literal), "literal value is stored");
assert_equal(value, read_literal, "settings preserve literal quotes");
}
// Test binary data (base64 encoded)
const std::vector<uint8_t> test_binary = {0x00, 0x01, 0x02, 0xFF, 0xFE, 0xFD};
settings->write("test_section", "binary_value", core::cspan{test_binary.data(), test_binary.size()});
std::vector<uint8_t> read_buffer(test_binary.size());
size_t read_len = read_buffer.size();
assert_equal(true, settings->read("test_section", "binary_value", read_buffer.data(), read_len), "read binary",
"INI file settings");
assert_equal(test_binary.size(), read_len, "binary length", "INI file settings");
for (size_t i = 0; i < test_binary.size(); ++i)
{
assert_equal(static_cast<uint32_t>(test_binary[i]), static_cast<uint32_t>(read_buffer[i]), "binary byte",
"INI file settings");
}
}
// Builds before 1.27.3 wrote the recent lists unquoted and the INI reader stripped a quote pair from
// each end, so an upgraded profile can hold an entry made of several paths glued by stray quotes.
// The value below is the shape a real profile was found holding.
static void should_drop_damaged_recent_entries()
{
const auto root = core::windows_path_semantics ? "C:\\Users\\someone\\"s : "/home/someone/"s;
const auto damaged =
std::format(R"({0}Pictures"' "{0}Videos" "{0}Music" "{0}OneDrive - Work\Desktop" '"{0}Downloads)", root);
assert_equal(true, recent_state::is_damaged_entry(std::format(R"({0}Pictures"' "{0}Videos)", root)),
"a quote wedged inside a path is damage");
for (const auto& healthy :
{root + "Pictures", std::format(R"({}photos "new york")", root), "\"" + root + "My Photos\" beach",
"Bob's \"party\""s, "@photo beach"s, std::format(R"({}Photos loc:"Boulder City")", root),
std::format(R"({}Photos -"draft")", root), std::format(R"({}Bob's photos tag:"summer")", root)})
{
assert_equal(false, recent_state::is_damaged_entry(healthy), "a real entry is kept", healthy);
}
{
// A folder-scoped search with a quoted term is ordinary recent text and must survive a restart.
const auto search = std::format(R"({}Photos loc:"Boulder City")", root);
const auto search_folder = test_temps.folder().combine("ini-recent-search");
platform::create_folder(search_folder);
const auto store = platform::create_ini_file_settings(search_folder);
recent_state saved;
saved.add(search);
saved.write("", "recent_searches", store);
recent_state loaded;
loaded.read("", "recent_searches", platform::create_ini_file_settings(search_folder));
assert_equal(1_z, loaded.items().size(), "the quoted search is reloaded");
assert_equal(search, loaded.items().front(), "and reloaded exactly");
}
const auto settings_folder = test_temps.folder().combine("ini-recent");
platform::create_folder(settings_folder);
const auto settings = platform::create_ini_file_settings(settings_folder);
settings->write("", "recent_searches", damaged + " " + root + "Kept");
assert_equal(true, recent_state::is_damaged_entry(std::format(R"('"{}Downloads)", root)),
"stray quotes leading a path are damage");
recent_state recents;
recents.read("", "recent_searches", settings);
const std::vector<std::string> expected{root + "Videos", root + "Music", root + R"(OneDrive - Work\Desktop)",
root + "Kept"};
assert_equal(core::combine(expected, "|", false), core::combine(recents.items(), "|", false),
"exactly the readable entries load, in order");
recents.write("", "recent_searches", settings);
recent_state reread;
reread.read("", "recent_searches", settings);
assert_equal(true, recents.items() == reread.items(), "the cleaned list round-trips");
}
#ifndef _WIN32
static void should_commit_linux_ini_file_settings_after_durable_save()
{
const auto settings_folder = test_temps.folder().combine("linux-ini-settings");
platform::create_folder(settings_folder);
const auto settings_path = settings_folder.combine_file("diffractor.ini");
auto settings = platform::create_ini_file_settings(settings_folder);
assert_equal(true, settings->write("test_section", "string_value", "original"), "initial write");
for (const auto failure :
{platform::linux_settings_test_failure::after_open, platform::linux_settings_test_failure::after_write,
platform::linux_settings_test_failure::before_replace})
{
platform::test_linux_settings_failure(failure);
assert_equal(false, settings->write("test_section", "string_value", "updated"), "failed write reports false");
platform::test_linux_settings_failure(platform::linux_settings_test_failure::none);
std::string same_instance;
assert_equal(true, settings->read("test_section", "string_value", same_instance),
"same instance still has committed value");
assert_equal("original", same_instance, "failed write does not publish uncommitted value");
assert_equal(false, platform::exists(settings_folder.combine_file(".diffractor.ini.tmp")),
"failed write removes stage");
const auto reopened = platform::create_ini_file_settings(settings_folder);
std::string reopened_value;
assert_equal(true, reopened->read("test_section", "string_value", reopened_value),
"reopened settings read committed value");
assert_equal("original", reopened_value, "failed write preserves on-disk value");
assert_equal(true, platform::exists(settings_path), "settings file remains present");
}
assert_equal(true, settings->write("test_section", "string_value", "updated"), "write succeeds after failures");
const auto reopened = platform::create_ini_file_settings(settings_folder);
std::string reopened_value;
assert_equal(true, reopened->read("test_section", "string_value", reopened_value), "reopened updated value");
assert_equal("updated", reopened_value, "successful write reaches disk");
}
static void should_skip_unchanged_linux_ini_file_settings()
{
const auto settings_folder = test_temps.folder().combine("linux-ini-unchanged");
platform::create_folder(settings_folder);
auto settings = platform::create_ini_file_settings(settings_folder);
platform::test_linux_reset_settings_save_count();
assert_equal(true, settings->write("test_section", "string_value", "same"), "initial write");
const auto saves_after_first = platform::test_linux_settings_save_count();
assert_equal(true, saves_after_first > 0, "initial write saves");
assert_equal(true, settings->write("test_section", "string_value", "same"), "unchanged write succeeds");
assert_equal(saves_after_first, platform::test_linux_settings_save_count(), "unchanged write does not save");
}
static void should_commit_linux_ini_file_settings_from_owned_stage()
{
const auto settings_folder = test_temps.folder().combine("linux-ini-owned-stage");
platform::create_folder(settings_folder);
auto first = platform::create_ini_file_settings(settings_folder);
auto second = platform::create_ini_file_settings(settings_folder);
assert_equal(true, first->write("test_section", "string_value", "original"), "initial write");
bool nested = false;
platform::test_linux_before_settings_replace = [&]
{
if (nested) return;
nested = true;
platform::test_linux_before_settings_replace = {};
assert_equal(true, second->write("test_section", "string_value", "second"), "nested write");
};
const auto first_write = first->write("test_section", "string_value", "first");
platform::test_linux_before_settings_replace = {};
assert_equal(true, first_write, "outer write succeeds with its own stage");
const auto reopened = platform::create_ini_file_settings(settings_folder);
std::string value;
assert_equal(true, reopened->read("test_section", "string_value", value), "reopened setting");
assert_equal("first", value, "outer complete write wins with complete bytes");
}
#endif
static void should_rename_with_substitutions()
{
null_async_strategy as;
const location_cache locations;
index_state index(as, locations);
const core::file_path src_path(test_files_folder(), "Test.jpg");
const auto save_path_1 = test_temps.next_path(".jpg");
const auto save_path_2 = test_temps.next_path(".jpg");
platform::copy_file(src_path, save_path_1, false, false);
const auto test_item = load_item(index, save_path_1, false);
assert_equal(true, test_item->rename(index, save_path_2.file_name_without_extension()).success(), "can rename");
assert_equal(save_path_2.name(), test_item->name(), "renamed");
assert_equal(true, platform::exists(save_path_2), "renamed exists");
// Verify item can be found at new path after rename
const auto reloaded = load_item(index, save_path_2, false);
assert_equal(save_path_2.name(), reloaded->name(), "index finds renamed item");
}
static void should_format_rename()
{
assert_equal("photo-005", format_sequence("original", "photo-###", 5), "sequence format");
assert_equal("photo-042", format_sequence("original", "photo-###", 42), "sequence zero pad");
assert_equal("photo-1000", format_sequence("original", "photo-###", 1000), "sequence does not truncate");
assert_equal("trip-0001", format_sequence("original", "trip-####", 1), "four digit sequence");
assert_equal("riginal", format_sequence("original", "???????", 0), "question mark substitution");
assert_equal("al-file", format_sequence("original", "?\?-file", 0), "mixed question mark substitution");
// Typed below zero, a start number has no digits to give: each one taken from it was a byte from
// before the digit table.
assert_equal("photo-000", format_sequence("original", "photo-###", -3), "a negative start counts from zero");
}
// The TV template renders as release names and media servers write them: two-digit seasons and episodes, and
// E00 for a special. It used to render Chernobyl.S1EUnknown.
static void should_rename_episodes_with_padded_numbers()
{
const auto episode = std::make_shared<prop::item_metadata>();
episode->show = core::cache("Chernobyl");
episode->title = core::cache("Please Remain Calm");
episode->season = 1;
episode->episode = prop::number_pair(5, 0);
assert_equal("Chernobyl.S01E05.Please Remain Calm",
prop::replace_tokens("{show}.S{season}E{episode}.{title}", episode, "original", {}), "an episode");
const auto special = std::make_shared<prop::item_metadata>(*episode);
special->season = 3;
special->episode = {0, 0};
special->is_special = true;
assert_equal("Chernobyl.S03E00.Please Remain Calm",
prop::replace_tokens("{show}.S{season}E{episode}.{title}", special, "original", {}), "a special");
const auto film = std::make_shared<prop::item_metadata>();
film->title = core::cache("Dont Look Up");
film->year = 2021;
assert_equal("Dont Look Up (2021)", prop::replace_tokens("{title} ({year})", film, "original", {}), "a film");
}
static void should_rename_name_token_without_extension()
{
df::item_set items;
const auto item = std::make_shared<df::item_element>(core::file_path(test_files_folder(), "Test.jpg"),
df::index_file_item{});
items.add(item);
const auto renames = calc_item_renames(items, "{name}-edited", 1, collision_policy::block_run);
assert_equal(1ULL, static_cast<uint64_t>(renames.size()), "one rename planned");
assert_equal("Test-edited", renames.front().new_name, "name token excludes extension");
}
static void should_reject_unusable_rename_targets()
{
df::item_set items;
items.add(
std::make_shared<df::item_element>(core::file_path(test_files_folder(), "Test.jpg"), df::index_file_item{}));
const auto empty_template = calc_item_renames(items, "", 1, collision_policy::block_run);
assert_equal(false, can_rename_items(empty_template), "an empty template names nothing");
#ifdef _WIN32
// Windows drops a trailing space, so the file would not carry the name the preview shows, and a
// device name is not a file at all. Neither is true of a filesystem that takes the name as given.
const auto trailing_space = calc_item_renames(items, "photo ", 1, collision_policy::block_run);
assert_equal("photo ", trailing_space.front().new_name, "the preview shows the template result");
assert_equal(false, can_rename_items(trailing_space), "a trailing space is rejected");
const auto device_name = calc_item_renames(items, "con", 1, collision_policy::block_run);
assert_equal(false, can_rename_items(device_name), "a reserved device name is rejected");
#endif
const auto usable = calc_item_renames(items, "photo", 1, collision_policy::block_run);
assert_equal(true, can_rename_items(usable), "an ordinary name is still accepted");
}
static void should_reject_duplicate_rename_targets()
{
df::item_set items;
items.add(
std::make_shared<df::item_element>(core::file_path(test_files_folder(), "Test.jpg"), df::index_file_item{}));
items.add(
std::make_shared<df::item_element>(core::file_path(test_files_folder(), "Small.jpg"), df::index_file_item{}));
const auto renames = calc_item_renames(items, "same", 1, collision_policy::block_run);
assert_equal(false, can_rename_items(renames), "duplicate rename targets rejected");
assert_equal(false, renames.front().valid, "first duplicate target invalid");
assert_equal(false, renames.back().valid, "second duplicate target invalid");
}
static std::vector<rename_source> make_rename_sources(const core::folder_path root,
const std::vector<std::string>& names)
{
const core::blob contents = {1};
std::vector<rename_source> sources;
for (const auto& name : names)
{
const auto path = root.combine_file(name + ".jpg");
platform::blob_save_to_file(contents, path);
rename_source source;
source.source = path;
source.original_name = name;
sources.emplace_back(std::move(source));
}
return sources;
}
static void should_plan_the_default_rename_template()
{
const auto root = test_temps.next_folder("rename-default");
const auto sources = make_rename_sources(root, {"alpha", "beta", "gamma"});
const auto renames = calc_item_renames(sources, "Item ###", 1, collision_policy::block_run);
assert_equal(3_z, renames.size(), "one row per item");
assert_equal("Item 001", renames.front().new_name, "first row uses the start sequence");
assert_equal(false, renames.front().collides, "a free destination does not collide");
assert_equal(true, renames.front().valid, "a free destination is valid");
assert_equal(true, can_rename_items(renames), "the default template can run");
null_async_strategy as;
const location_cache locations;
index_state index(as, locations);
const auto with_sidecar = root.combine_file("with-sidecar.jpg");
platform::copy_file(core::file_path(test_files_folder(), "Test.jpg"), with_sidecar, false, false);
platform::copy_file(core::file_path(test_files_folder(), "IMG_0604.xmp"), with_sidecar.extension(".xmp"), false,
false);
df::item_set items;
for (const auto& source : sources) items.add(load_item(index, source.source, false));
items.add(load_item(index, with_sidecar, false));
const auto item_renames = calc_item_renames(items, "Item ###", 1, collision_policy::block_run);
assert_equal(4_z, item_renames.size(), "one row per indexed item");
for (const auto& rename : item_renames)
assert_equal(true, rename.valid, std::format("{} is valid", rename.new_name));
assert_equal(true, can_rename_items(item_renames), "indexed items can run the default template");
}
static void should_rename_a_set_onto_names_it_is_vacating()
{
const auto root = test_temps.next_folder("rename-rotate");
auto sources = make_rename_sources(root, {"Item 001", "Item 002", "Item 003"});
std::ranges::reverse(sources);
const auto renames = calc_item_renames(sources, "Item ###", 1, collision_policy::block_run);
assert_equal(true, can_rename_items(renames), "a set may be renamed onto its own names");
assert_equal(0, count_rename_collisions(renames, collision_policy::block_run), "no row collides");
// A case-only rename frees nothing, so a second row cannot be cleared to take that name.
const auto shadowed = make_rename_sources(root, {"only"});
const auto case_only = calc_item_renames(shadowed, "ONLY", 1, collision_policy::block_run);
assert_equal(true, can_rename_items(case_only), "a case-only rename is not a collision");
}
// Rename used to revalidate by existence alone. A source replaced between the review and the run was
// then moved under a name chosen for content the user never saw, and under Replace a destination
// that had become a different file was written over. The plan records the identity the run is held
// to, which is the same test Sync makes.
static void should_record_rename_identity()
{
const auto root = test_temps.next_folder("rename-identity");
const auto sources = make_rename_sources(root, {"alpha"});
const auto occupied = root.combine_file("renamed.jpg");
platform::blob_save_to_file(core::blob{1, 2, 3}, occupied);
const auto renames = calc_item_renames(sources, "renamed", 1, collision_policy::replace);
assert_equal(1_z, renames.size(), "one row");
const auto& row = renames.front();
assert_equal(true, row.source_attributes.exists(), "the source identity was recorded");
assert_equal(true, row.destination_attributes.exists(), "so was the destination the row will replace");
assert_equal(true, unchanged_since_analysis(row.source, row.source_attributes.modified, row.source_attributes.size),
"an untouched source still matches the review");
assert_equal(true,
unchanged_since_analysis(row.destination, row.destination_attributes.modified,
row.destination_attributes.size),
"and so does an untouched destination");
// Both paths still exist, which is all the run used to ask. Only the recorded identity says the
// content behind them is no longer what was reviewed.
platform::blob_save_to_file(core::blob{1, 2, 3, 4, 5}, row.source);
platform::blob_save_to_file(core::blob{9}, row.destination);
assert_equal(true, platform::exists(row.source), "the source path is still occupied");
assert_equal(true, platform::exists(row.destination), "and so is the destination path");
assert_equal(false,
unchanged_since_analysis(row.source, row.source_attributes.modified, row.source_attributes.size),
"a rewritten source no longer matches the review");
assert_equal(false,
unchanged_since_analysis(row.destination, row.destination_attributes.modified,
row.destination_attributes.size),
"nor does a destination that became another file");
}
static void should_cascade_skipped_rename_rows()
{
const auto root = test_temps.next_folder("rename-cascade");
// Item 001 is not part of the plan, so the row that wants it can only be skipped - which leaves
// Item 002 where it is, so the row that was cleared to take Item 002 has to be skipped too.
const auto occupied = make_rename_sources(root, {"Item 001"});
const auto sources = make_rename_sources(root, {"Item 002", "beta"});
const auto renames = calc_item_renames(sources, "Item ###", 1, collision_policy::skip);
assert_equal(true, renames.front().skipped, "the blocked row is skipped");
assert_equal(true, renames.back().skipped, "the row waiting on it is skipped too");
assert_equal(false, can_rename_items(renames), "a plan that would write nothing cannot run");
}
static void should_group_rename_sidecar_collisions()
{
const auto root = test_temps.folder().combine(std::format("rename-sidecar-{}", core::tick_count()));
platform::create_folder(root);
const auto source = root.combine_file("photo.jpg");
const auto sidecar = root.combine_file("photo.xmp");
const core::blob contents = {1};
platform::blob_save_to_file(contents, source);
platform::blob_save_to_file(contents, sidecar);
platform::blob_save_to_file(contents, root.combine_file("renamed.xmp"));
rename_source item;
item.source = source;
item.original_name = "photo";
item.sidecars.emplace_back(sidecar);
const auto blocked = calc_item_renames(std::vector{item}, "renamed", 1, collision_policy::block_run);
assert_equal(false, can_rename_items(blocked), "sidecar collision blocks whole rename");
const auto renamed = calc_item_renames(std::vector{item}, "renamed", 1, collision_policy::auto_rename);
assert_equal(true, can_rename_items(renamed), "sidecar collision can auto-rename whole group");
assert_equal("renamed (2).jpg", renamed.front().destination.name(), "primary uses shared suffix");
assert_equal("renamed (2).xmp", renamed.front().sidecars.front().second.name(), "sidecar uses shared suffix");
platform::delete_items({}, {root}, false);
}
// A video's subtitles name their language, and whether they are forced, after its name. Moved with it, each keeps
// what it adds, so two subtitles with one extension never meet on one name; and a new name with a dot keeps all of it.
static void should_rename_subtitles_with_their_language()
{
const auto root = test_temps.folder().combine(std::format("rename-subtitles-{}", core::tick_count()));
platform::create_folder(root);
const core::blob contents = {1};
const auto video = root.combine_file("Movie.mkv");
const auto english = root.combine_file("Movie.en.srt");
const auto forced = root.combine_file("Movie.English.forced.srt");
for (const auto& f : {video, english, forced}) platform::blob_save_to_file(contents, f);
rename_source item;
item.source = video;
item.original_name = "Movie";
item.sidecars = {english, forced};
const auto plan = calc_item_renames(std::vector{item}, "Film", 1, collision_policy::block_run);
assert_equal(true, can_rename_items(plan), "the subtitles do not meet on one name");
assert_equal(2_z, plan.empty() ? 0_z : plan.front().sidecars.size(), "both move with the video");
if (!plan.empty() && plan.front().sidecars.size() == 2)
{
assert_equal("Film.en.srt"sv, plan.front().sidecars[0].second.name().sv(), "each keeps its language");
assert_equal("Film.English.forced.srt"sv, plan.front().sidecars[1].second.name().sv(), "and that it is forced");
}
assert_equal("The.Film.en.srt"sv, moved_sidecar_path(video, root.combine_file("The.Film.mkv"), english).name().sv(),
"a new name with a dot keeps all of it");
assert_equal("New.xmp"sv,
moved_sidecar_path(root.combine_file("IMG_1.CR2"), root.combine_file("New.CR2"),
root.combine_file("Other.xmp"))
.name()
.sv(),
"a sidecar named for another file keeps only its extension");
platform::delete_items({}, {root}, false);
}
// A RAW and the camera's JPEG share a sidecar by name, and both rows moved it: the second move failed
// its row, or with the JPEG first the RAW's metadata went to the JPEG's new name.
static void should_rename_a_shared_sidecar_with_the_raw_that_reads_it()
{
const auto root = test_temps.folder().combine(std::format("rename-shared-sidecar-{}", core::tick_count()));
platform::create_folder(root);
const auto sidecar = root.combine_file("IMG_1.xmp");
const core::blob contents = {1};
platform::blob_save_to_file(contents, root.combine_file("IMG_1.CR2"));
platform::blob_save_to_file(contents, root.combine_file("IMG_1.JPG"));
platform::blob_save_to_file(contents, sidecar);
rename_source raw;
raw.source = root.combine_file("IMG_1.CR2");
raw.original_name = "IMG_1";
raw.sidecars.emplace_back(sidecar);
auto jpeg = raw;
jpeg.source = root.combine_file("IMG_1.JPG");
for (const auto& order : {std::vector{raw, jpeg}, std::vector{jpeg, raw}})
{
const auto plan = calc_item_renames(order, "Trip ###", 1, collision_policy::block_run);
assert_equal(2_z, plan.size(), "both files are planned");
assert_equal(1,
static_cast<int>(
std::ranges::count_if(plan, [](const rename_item& r) { return !r.sidecars.empty(); })),
"the shared sidecar moves once");
for (const auto& r : plan)
{
if (r.sidecars.empty()) continue;
assert_equal(".CR2"s, std::string(r.source.extension()), "with the RAW, which reads it");
assert_equal(std::string(r.destination.file_name_without_extension()) + ".xmp",
std::string(r.sidecars.front().second.name().sv()), "under the RAW's new name");
}
assert_equal(true, can_rename_items(plan), "and the pair is renamed together");
}
platform::delete_items({}, {root}, false);
}
static void should_plan_unique_convert_outputs()
{
std::vector<convert_source> sources;
sources.emplace_back(core::file_path("c:\\one\\photo.jpg"), sizei{}, core::cached{});
sources.emplace_back(core::file_path("c:\\two\\photo.png"), sizei{}, core::cached{});
const auto plan = plan_convert_outputs(core::folder_path("c:\\destination"), sources, ".webp",
collision_policy::block_run);
assert_equal(2_z, plan.size(), "all conversion sources planned");
assert_equal("photo.webp", plan[0].destination.name(), "first conversion keeps basename");
assert_equal("photo (2).webp", plan[1].destination.name(), "duplicate conversion basename is suffixed");
assert_equal(false, plan[0].destination == plan[1].destination, "conversion outputs are unique");
}
// "Limit output dimensions" is a ceiling. The review shows an image within it at its own size, and the
// run wrote it enlarged to the limit - over the original, with Replace and an in-place destination.
static void should_limit_only_converted_images_over_the_limit()
{
assert_equal(0, convert_max_side({1000, 800}, 2000), "an image within the limit keeps its size");
assert_equal(0, convert_max_side({2000, 1500}, 2000), "and one exactly at it");
assert_equal(2000, convert_max_side({4000, 3000}, 2000), "a larger one is reduced");
assert_equal(2000, convert_max_side({1000, 4000}, 2000), "whichever side is longer");
assert_equal(2000, convert_max_side({}, 2000), "one whose size is not known yet takes the limit");
assert_equal(0, convert_max_side({4000, 3000}, 0), "no limit, no resize");
}
// A destination that names another row's source is a file this run reads. Writing it destroyed an
// input the review listed as a source, and that row then converted whatever the earlier one had
// just written over it. Ordering matters: the clobbering row is planned first, so the source it
// lands on has not yet claimed its own destination.
static void should_not_plan_a_convert_output_over_a_source()
{
std::vector<convert_source> sources;
sources.emplace_back(core::file_path("c:\\a\\photo.png"), sizei{}, core::cached{});
sources.emplace_back(core::file_path("c:\\destination\\photo.jpg"), sizei{}, core::cached{});
const auto plan = plan_convert_outputs(core::folder_path("c:\\destination"), sources, ".jpg",
collision_policy::replace);
assert_equal(2_z, plan.size(), "both conversion sources planned");
for (const auto& entry : plan)
{
for (const auto& source : sources)
{
if (entry.source.path == source.path) continue;
assert_equal(false, entry.destination == source.path, "a destination never names another row's source");
}
}
assert_equal(sources[0].path.str(), plan[0].source.path.str(), "the row planned first is the one from elsewhere");
assert_equal("photo (2).jpg", plan[0].destination.name(), "and it is moved off the other row's source");
assert_equal("photo.jpg", plan[1].destination.name(), "a row may still convert itself in place");
}
// A recipient sees a shared copy under its staged name, so two photos named alike in different
// folders must not land on one name, and a file the options leave alone goes as itself. Breaking
// the free-name step fails the "(2)" row; skipping the clear fails the stale row.
static void should_prepare_shared_copies_under_their_own_names()
{
const auto root = test_temps.next_folder("share");
const auto staging = root.combine("staging");
const auto one = root.combine("one");
const auto two = root.combine("two");
platform::create_folder(staging);
platform::create_folder(one);
platform::create_folder(two);
const auto png = test_files_folder().combine("excluded1").combine_file("gamma.png");
const auto jpeg = root.combine_file("Progressive.jpg");
const std::vector sources = {one.combine_file("photo.png"), two.combine_file("photo.png"), jpeg};
platform::copy_file(png, sources[0], false, false);
platform::copy_file(png, sources[1], false, false);
platform::copy_file(test_files_folder().combine("excluded1").combine_file("Progressive.jpg"), jpeg, false, false);
const auto source_bytes = platform::blob_from_file(sources[0]);
const auto stale = staging.combine_file("stale.jpg");
platform::blob_save_to_file(core::blob{1}, stale);
null_item_results_ui status;
outgoing_options convert;
convert.convert_to_jpeg = true;
// Whether a share left a file is asked of the folder's listing, which is what the clear reads. On a
// network share, which `dd bean` stages on, the client answers an existence check from its cache
// for some seconds after a delete, while the listing is current.
const auto staged = [&staging](const core::file_path path)
{
const auto listing = platform::iterate_file_items(staging, true).files;
return std::ranges::any_of(listing, [&path](const platform::file_info& f)
{ return core::icmp(f.name.sv(), path.name()) == 0; });
};
const auto converted = prepare_outgoing_files(sources, convert, staging, status);
assert_equal(true, converted.success, "the conversion is prepared");
assert_equal(3_z, converted.paths.size(), "one outgoing file per source");
assert_equal(staging.combine_file("photo.jpg").str(), converted.paths[0].str(), "the copy keeps its name");
assert_equal(staging.combine_file("photo (2).jpg").str(), converted.paths[1].str(),
"a second photo of that name does not overwrite the first");
assert_equal(jpeg.str(), converted.paths[2].str(), "a JPEG with nothing to convert goes as itself");
assert_equal(false, staged(stale), "what the previous share staged is cleared");
assert_equal(true, platform::blob_from_file(sources[0]) == source_bytes, "the source is unchanged");
const auto copy_bytes = platform::blob_from_file(converted.paths[1]);
assert_equal(true, copy_bytes.size() > 2 && copy_bytes[0] == 0xFF && copy_bytes[1] == 0xD8, "the copy is a JPEG");
outgoing_options zip;
zip.zip = true;
const auto zipped = prepare_outgoing_files(sources, zip, staging, status);
assert_equal(true, zipped.success, "the archive is prepared");
assert_equal(1_z, zipped.paths.size(), "the files go as one archive");
assert_equal("items.zip", zipped.paths.front().name(), "named for what it holds");
const auto entries = df::zip_file::list(zipped.paths.front());
assert_equal(3_z, entries.size(), "holding every source");
assert_equal("photo.png", entries[0].filename, "an entry keeps its name");
assert_equal("photo (2).png", entries[1].filename, "a second file of that name does not replace it on extraction");
assert_equal(false, staged(converted.paths[0]), "the earlier share's copies are cleared");
const auto unchanged = prepare_outgoing_files(sources, {}, staging, status);
assert_equal(true, unchanged.success, "nothing to prepare still succeeds");
assert_equal(sources.size(), unchanged.paths.size(), "every source goes");
assert_equal(sources[1].str(), unchanged.paths[1].str(), "as itself");
assert_equal(true, staged(zipped.paths.front()), "and nothing staged is cleared when nothing is written");
// The fixture is 256 pixels square. A limit above that must not enlarge it, which is what the
// scale edit does unless the size is checked first.
outgoing_options limit;
limit.max_side = 1024;
const auto inside = prepare_outgoing_files({jpeg}, limit, staging, status);
assert_equal(jpeg.str(), inside.paths.front().str(), "a photo already inside the limit goes as itself");
limit.max_side = 128;
const auto limited = prepare_outgoing_files({jpeg}, limit, staging, status);
assert_equal(staging.combine_file("Progressive.jpg").str(), limited.paths.front().str(),
"a photo beyond the limit goes as a copy");
files codecs;
const auto limited_size =
codecs.scan_file(limited.paths.front(), false, files::file_type_from_name(limited.paths.front())).dimensions();
assert_equal(128, std::max(limited_size.cx, limited_size.cy), "its longest side is the limit");
}
static void should_adjust_item_dates_from_snapshot()
{
const core::date_t original_start(2025, 8, 16, 18, 11, 56);
const core::date_t new_start(2025, 8, 17, 9, 30, 0);
constexpr auto offset = 10 * core::date_t::intervals_per_second;
assert_equal(new_start + offset, adjusted_item_date(original_start + offset, new_start, original_start),
"dated item preserves offset");
assert_equal(new_start, adjusted_item_date({}, new_start, original_start), "undated item uses new start");
// The row says which tag it is about to shift, so a selection whose files are dated by different
// things is visible before the run rather than after it.
const auto with_shutter = std::make_shared<prop::item_metadata>();
with_shutter->dates.add(prop::date_source::exif_original, core::date_t(2025, 8, 16, 18, 11, 56));
with_shutter->dates.add(prop::date_source::file_modified, core::date_t(2026, 8, 19, 21, 30, 0));
assert_equal("EXIF DateTimeOriginal", adjust_date_source_name(with_shutter), "the shutter answers first");
const auto scanned = std::make_shared<prop::item_metadata>();
scanned->dates.add(prop::date_source::xmp_create, core::date_t(2019, 5, 4, 9, 0, 0));
assert_equal("XMP xmp:CreateDate", adjust_date_source_name(scanned), "the rung below it answers next");
// Mirrors calc_media_created, which falls through to the filesystem when nothing else answers.
assert_equal("File created", adjust_date_source_name(nullptr), "an unscanned file shifts its own stamp");
assert_equal("File created", adjust_date_source_name(std::make_shared<prop::item_metadata>()),
"so does a file carrying no date at all");
}
#ifdef _WIN32
// The numbers are MAPI's own result codes, so there is nothing to classify where MAPI is absent.
static void should_classify_mapi_results()
{
assert_equal(true, platform::classify_mapi_send_result(0) == platform::mapi_send_result::sent, "MAPI success");
assert_equal(true, platform::classify_mapi_send_result(1) == platform::mapi_send_result::canceled,
"MAPI user abort");
assert_equal(true, platform::classify_mapi_send_result(3) == platform::mapi_send_result::failed,
"MAPI login failure");
}
#endif
// Records what a run reported for each row so revalidation decisions can be asserted.
struct recording_status final : df::status_i
{
std::vector<std::pair<std::string, item_status>> items;
// The first completion only, as the views show it: a later one is ignored.
std::string completion;
bool completed = false;
bool canceled = false;
void start_item(std::string_view) override {}
void end_item(const std::string_view name, const item_status status) override { items.emplace_back(name, status); }
bool has_failures() const override
{
return std::ranges::any_of(items, [](const auto& i) { return i.second == item_status::fail; });
}
void abort(std::string_view) override {}
void complete(const std::string_view message) override
{
if (completed) return;
completion = message;
completed = true;
}
void show_errors() override {}
void message(std::string_view, int64_t, int64_t) override {}
void show_message(std::string_view) override {}
bool is_canceled() const override { return canceled; }
void wait_for_complete() const override {}
item_status status_of(const std::string_view name) const
{
const auto found = std::ranges::find_if(items, [name](const auto& i) { return i.first == name; });
return found == items.end() ? item_status::cancel : found->second;
}
};
// Run holds every reviewed row to the file that was reviewed, one row at a time. A row whose file
// moved on is refused and reported; the rows that still match are still run.
static void should_revalidate_sync_rows()
{
const auto root = test_temps.next_folder("sync-revalidate");
const auto local = root.combine("local");
const auto remote = root.combine("remote");
platform::create_folder(local);
platform::create_folder(remote);
write_test_file(local.combine_file("keep.txt"), "keep");
write_test_file(local.combine_file("changed.txt"), "changed");
write_test_file(local.combine_file("claimed.txt"), "claimed");
core::index_roots roots;
roots.folders.emplace(local);
const auto analysis = sync_analysis(roots, remote, true, false, false, false, test_token);
assert_equal(true, analysis.valid, "sync analysis is valid");
assert_equal(3, static_cast<int>(count_sync_actions(analysis)), "three files to copy out");
// The source grows after review, so copying it would send content nobody approved.
write_test_file(local.combine_file("changed.txt"), "changed again");
// A destination the review found free is claimed by something else before the run reaches it.
write_test_file(remote.combine_file("claimed.txt"), "not yours");
const auto status = std::make_shared<recording_status>();
const auto run = sync_copy(status, analysis, test_token);
assert_equal(true, status->status_of("keep.txt") == item_status::success, "unchanged row runs");
assert_equal(true, status->status_of("changed.txt") == item_status::fail, "changed source is refused");
assert_equal(true, status->status_of("claimed.txt") == item_status::fail, "claimed destination is refused");
assert_equal(2, static_cast<int>(run.refused), "both refusals are reported so the run can say why");
assert_equal(true, platform::exists(remote.combine_file("keep.txt")), "unchanged row was copied");
assert_equal(false, platform::exists(remote.combine_file("changed.txt")), "refused row wrote nothing");
assert_equal("not yours"s, read_test_file(remote.combine_file("claimed.txt")),
"claimed destination was not overwritten");
}
// A delete was reviewed against the file's content, so that is what it is held to at run time.
static void should_revalidate_sync_deletes()
{
const auto root = test_temps.next_folder("sync-delete-revalidate");
const auto local = root.combine("local");
const auto remote = root.combine("remote");
platform::create_folder(local);
platform::create_folder(remote);
write_test_file(remote.combine_file("stale.txt"), "stale");
write_test_file(remote.combine_file("touched.txt"), "touched");
core::index_roots roots;
roots.folders.emplace(local);
const auto analysis = sync_analysis(roots, remote, false, false, false, true, test_token);
assert_equal(true, analysis.valid, "sync analysis is valid");
assert_equal(2, static_cast<int>(count_sync_actions(analysis, sync_action::delete_remote)),
"two remote files to delete");
write_test_file(remote.combine_file("touched.txt"), "touched after review");
const auto status = std::make_shared<recording_status>();
sync_copy(status, analysis, test_token);
assert_equal(true, status->status_of("stale.txt") == item_status::success, "unchanged file is deleted");
assert_equal(true, status->status_of("touched.txt") == item_status::fail, "changed file is not deleted");
assert_equal(false, platform::exists(remote.combine_file("stale.txt")), "unchanged file is gone");
assert_equal(true, platform::exists(remote.combine_file("touched.txt")), "changed file survives");
}
// A full-path exclusion is expressed in local collection coordinates. Sync's remote tree has to
// project each relative remote folder back into that same local scope before deciding whether it is
// in or out; otherwise reverse sync can copy excluded files back and mirror delete can remove them.
static void should_apply_sync_full_path_exclusions_to_remote_counterparts()
{
const auto root = test_temps.next_folder("sync-full-path-exclude");
const auto local = root.combine("local");
const auto remote = root.combine("remote");
const auto remote_private = remote.combine("Private");
const auto remote_nested = remote_private.combine("Nested");
const auto remote_cache = remote.combine("Cache.tmp");
platform::create_folder(local);
platform::create_folder(remote_nested);
platform::create_folder(remote_cache);
write_test_file(remote_private.combine_file("hidden.txt"), "hidden");
write_test_file(remote_nested.combine_file("nested.txt"), "nested");
write_test_file(remote_cache.combine_file("wildcard.txt"), "wildcard");
write_test_file(remote.combine_file("ordinary.txt"), "ordinary");
core::index_roots roots;
roots.folders.emplace(local);
roots.excludes.emplace(local.combine("Private"));
roots.exclude_wildcards.emplace(core::cache("*.tmp"));
const auto reverse_copy = sync_analysis(roots, remote, false, true, false, false, test_token);
assert_equal(true, reverse_copy.valid, "reverse sync remains valid");
assert_equal(1, static_cast<int>(count_sync_actions(reverse_copy, sync_action::copy_local)),
"only the ordinary sibling is copied back");
const auto remote_delete = sync_analysis(roots, remote, false, false, false, true, test_token);
assert_equal(true, remote_delete.valid, "remote delete sync remains valid");
assert_equal(1, static_cast<int>(count_sync_actions(remote_delete, sync_action::delete_remote)),
"only the ordinary sibling is proposed for remote deletion");
}
static void should_resolve_sync_exclusions_across_multiple_roots()
{
const auto root = test_temps.next_folder("sync-multi-root-exclude");
const auto local1 = root.combine("local1");
const auto local2 = root.combine("local2");
const auto remote = root.combine("remote");
platform::create_folder(local1.combine("Shots"));
platform::create_folder(local2.combine("Shots"));
platform::create_folder(remote.combine("Shots"));
write_test_file(local2.combine("Shots").combine_file("photo.txt"), "local2");
write_test_file(remote.combine("Shots").combine_file("photo.txt"), "remote");
core::index_roots roots;
roots.folders.emplace(local1);
roots.folders.emplace(local2);
roots.excludes.emplace(local1.combine("Shots"));
const auto disagreeing = sync_analysis(roots, remote, true, true, true, true, test_token);
assert_equal(false, disagreeing.valid, "excluded and included roots disagreeing is ambiguous");
assert_equal(true, disagreeing.reason == sync_invalid_reason::ambiguous_local_root,
"the disagreement keeps the ambiguous-root refusal");
roots.excludes.emplace(local2.combine("Shots"));
const auto all_excluded = sync_analysis(roots, remote, true, true, true, true, test_token);