@@ -358,13 +358,23 @@ private slots:
358
358
359
359
QVERIFY (fakeFolder.syncOnce ());
360
360
361
+ #if defined Q_OS_WINDOWS
361
362
QCOMPARE (completeSpy.findItem (fileWithSpaces1)->_status , SyncFileItem::Status::FileNameInvalid);
362
363
QCOMPARE (completeSpy.findItem (fileWithSpaces2)->_status , SyncFileItem::Status::FileNameInvalid);
363
364
QCOMPARE (completeSpy.findItem (fileWithSpaces3)->_status , SyncFileItem::Status::FileNameInvalid);
364
365
QCOMPARE (completeSpy.findItem (fileWithSpaces4)->_status , SyncFileItem::Status::FileNameInvalid);
365
366
QCOMPARE (completeSpy.findItem (fileWithSpaces5)->_status , SyncFileItem::Status::FileNameInvalid);
366
367
QCOMPARE (completeSpy.findItem (fileWithSpaces6)->_status , SyncFileItem::Status::FileNameInvalid);
367
368
QCOMPARE (completeSpy.findItem (QStringLiteral (" with spaces " ))->_status , SyncFileItem::Status::FileNameInvalid);
369
+ #else
370
+ QCOMPARE (completeSpy.findItem (fileWithSpaces1)->_status , SyncFileItem::Status::Success);
371
+ QCOMPARE (completeSpy.findItem (fileWithSpaces2)->_status , SyncFileItem::Status::Success);
372
+ QCOMPARE (completeSpy.findItem (fileWithSpaces3)->_status , SyncFileItem::Status::Success);
373
+ QCOMPARE (completeSpy.findItem (fileWithSpaces4)->_status , SyncFileItem::Status::Success);
374
+ QCOMPARE (completeSpy.findItem (fileWithSpaces5)->_status , SyncFileItem::Status::Success);
375
+ QCOMPARE (completeSpy.findItem (fileWithSpaces6)->_status , SyncFileItem::Status::Success);
376
+ QCOMPARE (completeSpy.findItem (QStringLiteral (" with spaces " ))->_status , SyncFileItem::Status::Success);
377
+ #endif
368
378
369
379
fakeFolder.syncEngine ().addAcceptedInvalidFileName (fakeFolder.localPath () + fileWithSpaces1);
370
380
fakeFolder.syncEngine ().addAcceptedInvalidFileName (fakeFolder.localPath () + fileWithSpaces2);
@@ -379,16 +389,14 @@ private slots:
379
389
fakeFolder.syncEngine ().setLocalDiscoveryOptions (LocalDiscoveryStyle::DatabaseAndFilesystem, {QStringLiteral (" foo" ), QStringLiteral (" bar" ), QStringLiteral (" bla" ), QStringLiteral (" A/foo" ), QStringLiteral (" A/bar" ), QStringLiteral (" A/bla" )});
380
390
QVERIFY (fakeFolder.syncOnce ());
381
391
392
+ #if defined Q_OS_WINDOWS
382
393
QCOMPARE (completeSpy.findItem (fileWithSpaces1)->_status , SyncFileItem::Status::Success);
383
394
QCOMPARE (completeSpy.findItem (fileWithSpaces2)->_status , SyncFileItem::Status::Success);
384
395
QCOMPARE (completeSpy.findItem (fileWithSpaces3)->_status , SyncFileItem::Status::Success);
385
396
QCOMPARE (completeSpy.findItem (fileWithSpaces4)->_status , SyncFileItem::Status::Success);
386
397
QCOMPARE (completeSpy.findItem (fileWithSpaces5)->_status , SyncFileItem::Status::Success);
387
398
QCOMPARE (completeSpy.findItem (fileWithSpaces6)->_status , SyncFileItem::Status::Success);
388
- #ifdef Q_OS_WINDOWS
389
399
QCOMPARE (completeSpy.findItem (QStringLiteral (" with spaces " ))->_status , SyncFileItem::Status::NormalError);
390
- #else
391
- QCOMPARE (completeSpy.findItem (QStringLiteral (" with spaces " ))->_status , SyncFileItem::Status::Success);
392
400
#endif
393
401
}
394
402
@@ -422,6 +430,44 @@ private slots:
422
430
}
423
431
}
424
432
433
+ void testCreateLocalPathsWithLeadingAndTrailingSpaces_syncOnSupportingOs ()
434
+ {
435
+ FakeFolder fakeFolder{FileInfo ()};
436
+ fakeFolder.localModifier ().mkdir (" A" );
437
+ QVERIFY (fakeFolder.syncOnce ());
438
+ QCOMPARE (fakeFolder.currentLocalState (), fakeFolder.currentRemoteState ());
439
+
440
+ const QString fileWithSpaces1 (" A/ space" );
441
+ const QString fileWithSpaces2 (" A/ space " );
442
+ const QString fileWithSpaces3 (" A/space " );
443
+ const QString folderWithSpaces1 (" A " );
444
+ const QString folderWithSpaces2 (" B " );
445
+
446
+ fakeFolder.localModifier ().insert (fileWithSpaces1);
447
+ fakeFolder.localModifier ().insert (fileWithSpaces2);
448
+ fakeFolder.localModifier ().insert (fileWithSpaces3);
449
+ fakeFolder.localModifier ().mkdir (folderWithSpaces1);
450
+ fakeFolder.localModifier ().mkdir (folderWithSpaces2);
451
+
452
+ ItemCompletedSpy completeSpy (fakeFolder);
453
+ completeSpy.clear ();
454
+
455
+ QVERIFY (fakeFolder.syncOnce ());
456
+
457
+ #if !defined Q_OS_WINDOWS
458
+ QCOMPARE (completeSpy.findItem (fileWithSpaces1)->_status , SyncFileItem::Status::Success);
459
+ QCOMPARE (completeSpy.findItem (fileWithSpaces2)->_status , SyncFileItem::Status::Success);
460
+ QCOMPARE (completeSpy.findItem (fileWithSpaces3)->_status , SyncFileItem::Status::Success);
461
+ QCOMPARE (completeSpy.findItem (folderWithSpaces1)->_status , SyncFileItem::Status::Success);
462
+ QCOMPARE (completeSpy.findItem (folderWithSpaces2)->_status , SyncFileItem::Status::Success);
463
+ QVERIFY (fakeFolder.remoteModifier ().find (fileWithSpaces1));
464
+ QVERIFY (fakeFolder.remoteModifier ().find (fileWithSpaces2));
465
+ QVERIFY (fakeFolder.remoteModifier ().find (fileWithSpaces3));
466
+ QVERIFY (fakeFolder.remoteModifier ().find (folderWithSpaces1));
467
+ QVERIFY (fakeFolder.remoteModifier ().find (folderWithSpaces2));
468
+ #endif
469
+ }
470
+
425
471
void testCreateFileWithTrailingSpaces_remoteGetRenamedManually ()
426
472
{
427
473
// On Windows we can't create files/folders with leading/trailing spaces locally. So, we have to fail those items. On other OSs - we just sync them down normally.
@@ -481,7 +527,15 @@ private slots:
481
527
QVERIFY (fakeFolder.syncOnce ());
482
528
483
529
QVERIFY (fakeFolder.currentRemoteState ().find (fileTrimmed));
530
+
531
+ #if defined Q_OS_WINDOWS
532
+ // no file with spaces on Windows
484
533
QVERIFY (!fakeFolder.currentRemoteState ().find (fileWithSpaces));
534
+ #else
535
+ // Linux/Mac OS allows spaces
536
+ QVERIFY (fakeFolder.currentRemoteState ().find (fileWithSpaces));
537
+ #endif
538
+
485
539
QVERIFY (fakeFolder.currentLocalState ().find (fileWithSpaces));
486
540
QVERIFY (fakeFolder.currentLocalState ().find (fileTrimmed));
487
541
}
0 commit comments