OCC::Result<OCC::Vfs::ConvertToPlaceholderResult, QString> OCC::CfApiWrapper::revertPlaceholder(const QString &path)
{
- const qint64 result = CfRevertPlaceholder(handleForPath(path).get(), CF_REVERT_FLAG_NONE, nullptr);
+ const auto result = CfRevertPlaceholder(handleForPath(path).get(), CF_REVERT_FLAG_NONE, nullptr);
if (result != S_OK) {
qCWarning(lcCfApiWrapper) << "Couldn't revert placeholder for" << path << ":" << QString::fromWCharArray(_com_error(result).ErrorMessage());
return {"Couldn't revert placeholder"};
QTest::newRow("skip local discovery") << false;
}
- void testUnexpectedNonPlaceholder()
+ void testReplaceFileByIdenticalFile()
{
FakeFolder fakeFolder{FileInfo{}};
auto vfs = setupVfs(fakeFolder);
// Create a new local (non-placeholder) file
fakeFolder.localModifier().insert("file0");
fakeFolder.localModifier().insert("file1");
+ CopyFile(QString(fakeFolder.localPath() + "file1").toStdWString().data(), QString(fakeFolder.localPath() + "file2").toStdWString().data(), false);
QVERIFY(!vfs->pinState("file0").isValid());
QVERIFY(!vfs->pinState("file1").isValid());
+ QVERIFY(!vfs->pinState("file2").isValid());
// Sync the files: files should be converted to placeholder files
QVERIFY(fakeFolder.syncOnce());
QVERIFY(vfs->pinState("file0").isValid());
QVERIFY(vfs->pinState("file1").isValid());
+ QVERIFY(vfs->pinState("file2").isValid());
// Sync again to ensure items are fully synced, otherwise test may succeed due to those pending changes.
QVERIFY(fakeFolder.syncOnce());
QVERIFY(fakeFolder.syncOnce());
QVERIFY(completeSpy.isEmpty());
- // Convert to regular file (may occur when file is replaced by another one)
- QVERIFY(cfapi::revertPlaceholder(fakeFolder.localPath() + "file1"));
+ // Replace file1 by identical file2: Windows will convert file1 to a regular (non-placeholder) file again.
+ CopyFile(QString(fakeFolder.localPath() + "file2").toStdWString().data(), QString(fakeFolder.localPath() + "file1").toStdWString().data(), false);
QVERIFY(vfs->pinState("file0").isValid());
QVERIFY(!vfs->pinState("file1").isValid());
+ QVERIFY(vfs->pinState("file2").isValid());
// Sync again: file should be correctly converted to placeholders
QVERIFY(fakeFolder.syncOnce());
QVERIFY(vfs->pinState("file0").isValid());
QVERIFY(vfs->pinState("file1").isValid());
+ QVERIFY(vfs->pinState("file2").isValid());
}
void testReplaceOnlineOnlyFile()