From: Christian Kamm Date: Thu, 20 Dec 2018 10:24:41 +0000 (+0100) Subject: vfs: Remove newFilesAreVirtual - use root PinState instead X-Git-Tag: archive/raspbian/3.16.7-1_deb13u1+rpi1~1^2~12^2~21^2~468^2~353 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=d956f518a8a769a371f83431522d7a8ed1ee89b7;p=nextcloud-desktop.git vfs: Remove newFilesAreVirtual - use root PinState instead This unifies how to deal with pin states. Also enable reading a folders direct pin state vs its effective pin state. --- diff --git a/src/common/syncjournaldb.cpp b/src/common/syncjournaldb.cpp index 7ccb38c79..f008175f9 100644 --- a/src/common/syncjournaldb.cpp +++ b/src/common/syncjournaldb.cpp @@ -2071,24 +2071,47 @@ void SyncJournalDb::markVirtualFileForDownloadRecursively(const QByteArray &path query.exec(); } -PinState SyncJournalDb::pinStateForPath(const QByteArray &path) +Optional SyncJournalDb::rawPinStateForPath(const QByteArray &path) { QMutexLocker lock(&_mutex); if (!checkConnect()) - return PinState::Unspecified; + return {}; + + auto &query = _getRawPinStateQuery; + ASSERT(query.initOrReset(QByteArrayLiteral( + "SELECT pinState FROM flags WHERE path == ?1;"), + _db)); + query.bindValue(1, path); + query.exec(); + + // no-entry means Inherited + if (!query.next()) + return PinState::Inherited; + + return static_cast(query.intValue(0)); +} + +Optional SyncJournalDb::effectivePinStateForPath(const QByteArray &path) +{ + QMutexLocker lock(&_mutex); + if (!checkConnect()) + return {}; - auto &query = _getPinStateQuery; + auto &query = _getEffectivePinStateQuery; ASSERT(query.initOrReset(QByteArrayLiteral( "SELECT pinState FROM flags WHERE" - " " IS_PREFIX_PATH_OR_EQUAL("path", "?1") + // explicitly allow "" to represent the root path + // (it'd be great if paths started with a / and "/" could be the root) + " (" IS_PREFIX_PATH_OR_EQUAL("path", "?1") " OR path == '')" " AND pinState is not null AND pinState != 0" " ORDER BY length(path) DESC;"), _db)); query.bindValue(1, path); query.exec(); + // If the root path has no setting, assume AlwaysLocal if (!query.next()) - return PinState::Unspecified; + return PinState::AlwaysLocal; return static_cast(query.intValue(0)); } diff --git a/src/common/syncjournaldb.h b/src/common/syncjournaldb.h index ddf5a1989..ca589b1d3 100644 --- a/src/common/syncjournaldb.h +++ b/src/common/syncjournaldb.h @@ -28,6 +28,7 @@ #include "common/utility.h" #include "common/ownsql.h" #include "common/syncjournalfilerecord.h" +#include "common/result.h" namespace OCC { class SyncJournalFileRecord; @@ -35,7 +36,7 @@ class SyncJournalFileRecord; /** Determines whether files should be available locally or not * * For new remote files the file's PinState is calculated by looking for - * the closest parent folder that isn't Unspecified. + * the closest parent folder that isn't Inherited. * * TODO: It seems to make sense to also store per-file PinStates. * Maybe these could communicate intent, similar to ItemTypeVirtualFileDownload @@ -43,7 +44,7 @@ class SyncJournalFileRecord; */ enum class PinState { /// Inherit the PinState of the parent directory (default) - Unspecified = 0, + Inherited = 0, /// Download file and keep it updated. AlwaysLocal = 1, /// File shall be virtual locally. @@ -261,15 +262,35 @@ public: void markVirtualFileForDownloadRecursively(const QByteArray &path); /** - * Gets the PinState for the path. + * Gets the PinState for the path without considering parents. * - * If the exact path has no entry or has an unspecified state, - * the state is inherited through the parent. + * If a path has no explicit PinState "Inherited" is returned. + * + * It's valid to use the root path "". + * + * Returns none on db error. + */ + Optional rawPinStateForPath(const QByteArray &path); + + /** + * Gets the PinState for the path after inheriting from parents. + * + * If the exact path has no entry or has an Inherited state, + * the state of the closest parent path is returned. + * + * It's valid to use the root path "". + * + * Never returns PinState::Inherited. If the root is "Inherited" + * or there's an error, "AlwaysLocal" is returned. + * + * Returns none on db error. */ - PinState pinStateForPath(const QByteArray &path); + Optional effectivePinStateForPath(const QByteArray &path); /** * Sets a path's pin state. + * + * It's valid to use the root path "". */ void setPinStateForPath(const QByteArray &path, PinState state); @@ -337,7 +358,8 @@ private: SqlQuery _getConflictRecordQuery; SqlQuery _setConflictRecordQuery; SqlQuery _deleteConflictRecordQuery; - SqlQuery _getPinStateQuery; + SqlQuery _getRawPinStateQuery; + SqlQuery _getEffectivePinStateQuery; SqlQuery _setPinStateQuery; /* Storing etags to these folders, or their parent folders, is filtered out. diff --git a/src/gui/accountsettings.cpp b/src/gui/accountsettings.cpp index a8cb24852..b58351e06 100644 --- a/src/gui/accountsettings.cpp +++ b/src/gui/accountsettings.cpp @@ -538,8 +538,6 @@ void AccountSettings::slotFolderWizardAccepted() if (folderWizard->property("useVirtualFiles").toBool()) { definition.virtualFilesMode = bestAvailableVfsMode(); - if (definition.virtualFilesMode != Vfs::Off) - definition.newFilesAreVirtual = true; } { @@ -572,6 +570,9 @@ void AccountSettings::slotFolderWizardAccepted() Folder *f = folderMan->addFolder(_accountState, definition); if (f) { + if (definition.virtualFilesMode != Vfs::Off && folderWizard->property("useVirtualFiles").toBool()) + f->setNewFilesAreVirtual(true); + f->journalDb()->setSelectiveSyncList(SyncJournalDb::SelectiveSyncBlackList, selectiveSyncBlackList); // The user already accepted the selective sync dialog. everything is in the white list diff --git a/src/gui/folder.cpp b/src/gui/folder.cpp index ffdabb55e..e43745a3c 100644 --- a/src/gui/folder.cpp +++ b/src/gui/folder.cpp @@ -649,13 +649,13 @@ void Folder::setSupportsVirtualFiles(bool enabled) bool Folder::newFilesAreVirtual() const { - return _definition.newFilesAreVirtual; + auto pinState = _journal.rawPinStateForPath(""); + return pinState && *pinState == PinState::OnlineOnly; } void Folder::setNewFilesAreVirtual(bool enabled) { - _definition.newFilesAreVirtual = enabled; - saveToSettings(); + _journal.setPinStateForPath("", enabled ? PinState::OnlineOnly : PinState::AlwaysLocal); } void Folder::saveToSettings() const @@ -691,8 +691,12 @@ void Folder::saveToSettings() const settings->beginGroup(settingsGroup); // Note: Each of these groups might have a "version" tag, but that's // currently unused. + settings->beginGroup(FolderMan::escapeAlias(_definition.alias)); FolderDefinition::save(*settings, _definition); + // Technically redundant, just for older clients + settings->setValue(QLatin1String("usePlaceholders"), newFilesAreVirtual()); + settings->sync(); qCInfo(lcFolder) << "Saved folder" << _definition.alias << "to settings, status" << settings->status(); } @@ -841,7 +845,6 @@ void Folder::setSyncOptions() opt._confirmExternalStorage = cfgFile.confirmExternalStorage(); opt._moveFilesToTrash = cfgFile.moveToTrash(); opt._vfs = _vfs; - opt._newFilesAreVirtual = _definition.newFilesAreVirtual; QByteArray chunkSizeEnv = qgetenv("OWNCLOUD_CHUNK_SIZE"); if (!chunkSizeEnv.isEmpty()) { @@ -1241,13 +1244,11 @@ void Folder::slotAboutToRemoveAllFiles(SyncFileItem::Direction dir, bool *cancel void FolderDefinition::save(QSettings &settings, const FolderDefinition &folder) { - settings.beginGroup(FolderMan::escapeAlias(folder.alias)); settings.setValue(QLatin1String("localPath"), folder.localPath); settings.setValue(QLatin1String("journalPath"), folder.journalPath); settings.setValue(QLatin1String("targetPath"), folder.targetPath); settings.setValue(QLatin1String("paused"), folder.paused); settings.setValue(QLatin1String("ignoreHiddenFiles"), folder.ignoreHiddenFiles); - settings.setValue(QLatin1String("usePlaceholders"), folder.newFilesAreVirtual); settings.setValue(QStringLiteral("virtualFilesMode"), Vfs::modeToString(folder.virtualFilesMode)); @@ -1263,13 +1264,11 @@ void FolderDefinition::save(QSettings &settings, const FolderDefinition &folder) settings.setValue(QLatin1String("navigationPaneClsid"), folder.navigationPaneClsid); else settings.remove(QLatin1String("navigationPaneClsid")); - settings.endGroup(); } bool FolderDefinition::load(QSettings &settings, const QString &alias, FolderDefinition *folder) { - settings.beginGroup(alias); folder->alias = FolderMan::unescapeAlias(alias); folder->localPath = settings.value(QLatin1String("localPath")).toString(); folder->journalPath = settings.value(QLatin1String("journalPath")).toString(); @@ -1277,7 +1276,6 @@ bool FolderDefinition::load(QSettings &settings, const QString &alias, folder->paused = settings.value(QLatin1String("paused")).toBool(); folder->ignoreHiddenFiles = settings.value(QLatin1String("ignoreHiddenFiles"), QVariant(true)).toBool(); folder->navigationPaneClsid = settings.value(QLatin1String("navigationPaneClsid")).toUuid(); - folder->newFilesAreVirtual = settings.value(QLatin1String("usePlaceholders")).toBool(); folder->virtualFilesMode = Vfs::WithSuffix; QString vfsModeString = settings.value(QStringLiteral("virtualFilesMode")).toString(); @@ -1291,8 +1289,6 @@ bool FolderDefinition::load(QSettings &settings, const QString &alias, folder->upgradeVfsMode = true; } - settings.endGroup(); - // Old settings can contain paths with native separators. In the rest of the // code we assum /, so clean it up now. folder->localPath = prepareLocalPath(folder->localPath); diff --git a/src/gui/folder.h b/src/gui/folder.h index 978fa6144..a1c891a95 100644 --- a/src/gui/folder.h +++ b/src/gui/folder.h @@ -63,18 +63,16 @@ public: bool ignoreHiddenFiles = false; /// Which virtual files setting the folder uses Vfs::Mode virtualFilesMode = Vfs::Off; - /// Whether new files are virtual - bool newFilesAreVirtual = false; /// The CLSID where this folder appears in registry for the Explorer navigation pane entry. QUuid navigationPaneClsid; /// Whether the vfs mode shall silently be updated if possible bool upgradeVfsMode = false; - /// Saves the folder definition, creating a new settings group. + /// Saves the folder definition into the current settings group. static void save(QSettings &settings, const FolderDefinition &folder); - /// Reads a folder definition from a settings group with the name 'alias'. + /// Reads a folder definition from the current settings group. static bool load(QSettings &settings, const QString &alias, FolderDefinition *folder); @@ -265,7 +263,10 @@ public: bool supportsVirtualFiles() const; void setSupportsVirtualFiles(bool enabled); - /** whether new remote files shall become virtual locally */ + /** whether new remote files shall become virtual locally + * + * This is the root folder pin state and can be overridden by explicit subfolder pin states. + */ bool newFilesAreVirtual() const; void setNewFilesAreVirtual(bool enabled); @@ -427,7 +428,7 @@ private: /// Reset when no follow-up is requested. int _consecutiveFollowUpSyncs; - SyncJournalDb _journal; + mutable SyncJournalDb _journal; QScopedPointer _fileLog; diff --git a/src/gui/folderman.cpp b/src/gui/folderman.cpp index b5fff9fa0..49a3ab286 100644 --- a/src/gui/folderman.cpp +++ b/src/gui/folderman.cpp @@ -222,6 +222,7 @@ void FolderMan::setupFoldersHelper(QSettings &settings, AccountStatePtr account, settings.endGroup(); FolderDefinition folderDefinition; + settings.beginGroup(folderAlias); if (FolderDefinition::load(settings, folderAlias, &folderDefinition)) { auto defaultJournalPath = folderDefinition.defaultJournalPath(account->account()); @@ -293,15 +294,23 @@ void FolderMan::setupFoldersHelper(QSettings &settings, AccountStatePtr account, Folder *f = addFolderInternal(std::move(folderDefinition), account.data(), std::move(vfs)); if (f) { + // Migrate the old "usePlaceholders" setting to the root folder pin state + if (settings.value(QLatin1String(versionC), 1).toInt() == 1 + && settings.value(QLatin1String("usePlaceholders"), false).toBool()) { + f->setNewFilesAreVirtual(true); + } + // Migration: Mark folders that shall be saved in a backwards-compatible way if (backwardsCompatible) f->setSaveBackwardsCompatible(true); if (foldersWithPlaceholders) f->setSaveInFoldersWithPlaceholders(); + scheduleFolder(f); emit folderSyncStateChange(f); } } + settings.endGroup(); } } diff --git a/src/gui/owncloudsetupwizard.cpp b/src/gui/owncloudsetupwizard.cpp index d402839d2..519fcaef0 100644 --- a/src/gui/owncloudsetupwizard.cpp +++ b/src/gui/owncloudsetupwizard.cpp @@ -637,14 +637,15 @@ void OwncloudSetupWizard::slotAssistantFinished(int result) folderDefinition.ignoreHiddenFiles = folderMan->ignoreHiddenFiles(); if (_ocWizard->useVirtualFileSync()) { folderDefinition.virtualFilesMode = bestAvailableVfsMode(); - if (folderDefinition.virtualFilesMode != Vfs::Off) - folderDefinition.newFilesAreVirtual = true; } if (folderMan->navigationPaneHelper().showInExplorerNavigationPane()) folderDefinition.navigationPaneClsid = QUuid::createUuid(); auto f = folderMan->addFolder(account, folderDefinition); if (f) { + if (folderDefinition.virtualFilesMode != Vfs::Off && _ocWizard->useVirtualFileSync()) + f->setNewFilesAreVirtual(true); + f->journalDb()->setSelectiveSyncList(SyncJournalDb::SelectiveSyncBlackList, _ocWizard->selectiveSyncBlacklist()); if (!_ocWizard->isConfirmBigFolderChecked()) { diff --git a/src/libsync/discovery.cpp b/src/libsync/discovery.cpp index 13f013efc..435cbcdb2 100644 --- a/src/libsync/discovery.cpp +++ b/src/libsync/discovery.cpp @@ -410,10 +410,14 @@ void ProcessDirectoryJob::processFileAnalyzeRemoteInfo( } // Turn new remote files into virtual files if the option is enabled. auto &opts = _discoveryData->_syncOptions; + if (!directoryPinState()) { + dbError(); + return; + } if (!localEntry.isValid() && item->_type == ItemTypeFile && opts._vfs->mode() != Vfs::Off - && directoryPinState() == PinState::OnlineOnly) { + && *directoryPinState() == PinState::OnlineOnly) { item->_type = ItemTypeVirtualFile; if (isVfsWithSuffix()) addVirtualFileSuffix(path._original); @@ -1331,17 +1335,14 @@ bool ProcessDirectoryJob::runLocalQuery() return true; } -PinState ProcessDirectoryJob::directoryPinState() +Optional ProcessDirectoryJob::directoryPinState() { - if (_pinStateCache) - return *_pinStateCache; - - // Get the path's pinstate and anchor to the root option - _pinStateCache = _discoveryData->_statedb->pinStateForPath(_currentFolder._original.toUtf8()); - if (*_pinStateCache == PinState::Unspecified) - _pinStateCache = _discoveryData->_syncOptions._newFilesAreVirtual ? PinState::OnlineOnly : PinState::AlwaysLocal; - - return *_pinStateCache; + if (!_pinStateCache) { + _pinStateCache = _discoveryData->_statedb->effectivePinStateForPath( + _currentFolder._original.toUtf8()); + // don't cache db errors, just retry next time + } + return _pinStateCache; } bool ProcessDirectoryJob::isVfsWithSuffix() const diff --git a/src/libsync/discovery.h b/src/libsync/discovery.h index 0ec44b940..bfb6856a3 100644 --- a/src/libsync/discovery.h +++ b/src/libsync/discovery.h @@ -181,7 +181,7 @@ private: bool runLocalQuery(); /** Retrieve and cache directory pin state */ - PinState directoryPinState(); + Optional directoryPinState(); QueryMode _queryServer; QueryMode _queryLocal; diff --git a/src/libsync/discoveryphase.cpp b/src/libsync/discoveryphase.cpp index cc0a47ee8..e97af0e7e 100644 --- a/src/libsync/discoveryphase.cpp +++ b/src/libsync/discoveryphase.cpp @@ -100,7 +100,7 @@ void DiscoveryPhase::checkSelectiveSyncNewFolder(const QString &path, RemotePerm } auto limit = _syncOptions._newBigFolderSizeLimit; - if (limit < 0 || (_syncOptions._vfs->mode() != Vfs::Off && _syncOptions._newFilesAreVirtual)) { + if (limit < 0 || _syncOptions._vfs->mode() != Vfs::Off) { // no limit, everything is allowed; return callback(false); } diff --git a/src/libsync/syncoptions.h b/src/libsync/syncoptions.h index f40954b04..8de39a789 100644 --- a/src/libsync/syncoptions.h +++ b/src/libsync/syncoptions.h @@ -44,9 +44,6 @@ struct SyncOptions /** Create a virtual file for new files instead of downloading. May not be null */ QSharedPointer _vfs; - /** True if new files shall be virtual */ - bool _newFilesAreVirtual = false; - /** The initial un-adjusted chunk size in bytes for chunked uploads, both * for old and new chunking algorithm, which classifies the item to be chunked * diff --git a/test/testsyncjournaldb.cpp b/test/testsyncjournaldb.cpp index cd42f0f4b..03c7a7475 100644 --- a/test/testsyncjournaldb.cpp +++ b/test/testsyncjournaldb.cpp @@ -324,56 +324,76 @@ private slots: { auto make = [&](const QByteArray &path, PinState state) { _db.setPinStateForPath(path, state); + auto pinState = _db.rawPinStateForPath(path); + QVERIFY(pinState); + QCOMPARE(*pinState, state); }; - auto get = [&](const QByteArray &path) { - return _db.pinStateForPath(path); + auto get = [&](const QByteArray &path) -> PinState { + auto state = _db.effectivePinStateForPath(path); + if (!state) { + QTest::qFail("couldn't read pin state", __FILE__, __LINE__); + return PinState::Inherited; + } + return *state; }; // Make a thrice-nested setup make("local", PinState::AlwaysLocal); make("online", PinState::OnlineOnly); - make("unspec", PinState::Unspecified); - for (auto base : {"local/", "online/", "unspec/"}) { - make(QByteArray(base) + "unspec", PinState::Unspecified); + make("inherit", PinState::Inherited); + for (auto base : {"local/", "online/", "inherit/"}) { + make(QByteArray(base) + "inherit", PinState::Inherited); make(QByteArray(base) + "local", PinState::AlwaysLocal); make(QByteArray(base) + "online", PinState::OnlineOnly); - for (auto base2 : {"local/", "online/", "unspec/"}) { - make(QByteArray(base) + base2 + "/unspec", PinState::Unspecified); + for (auto base2 : {"local/", "online/", "inherit/"}) { + make(QByteArray(base) + base2 + "/inherit", PinState::Inherited); make(QByteArray(base) + base2 + "/local", PinState::AlwaysLocal); make(QByteArray(base) + base2 + "/online", PinState::OnlineOnly); } } - // Baseline direct checks + // Baseline direct checks (the fallback for unset root pinstate is AlwaysLocal) QCOMPARE(get("local"), PinState::AlwaysLocal); QCOMPARE(get("online"), PinState::OnlineOnly); - QCOMPARE(get("unspec"), PinState::Unspecified); - QCOMPARE(get("nonexistant"), PinState::Unspecified); + QCOMPARE(get("inherit"), PinState::AlwaysLocal); + QCOMPARE(get("nonexistant"), PinState::AlwaysLocal); QCOMPARE(get("online/local"), PinState::AlwaysLocal); QCOMPARE(get("local/online"), PinState::OnlineOnly); - QCOMPARE(get("unspec/local"), PinState::AlwaysLocal); - QCOMPARE(get("unspec/online"), PinState::OnlineOnly); - QCOMPARE(get("unspec/unspec"), PinState::Unspecified); - QCOMPARE(get("unspec/nonexistant"), PinState::Unspecified); + QCOMPARE(get("inherit/local"), PinState::AlwaysLocal); + QCOMPARE(get("inherit/online"), PinState::OnlineOnly); + QCOMPARE(get("inherit/inherit"), PinState::AlwaysLocal); + QCOMPARE(get("inherit/nonexistant"), PinState::AlwaysLocal); // Inheriting checks, level 1 - QCOMPARE(get("local/unspec"), PinState::AlwaysLocal); + QCOMPARE(get("local/inherit"), PinState::AlwaysLocal); QCOMPARE(get("local/nonexistant"), PinState::AlwaysLocal); - QCOMPARE(get("online/unspec"), PinState::OnlineOnly); + QCOMPARE(get("online/inherit"), PinState::OnlineOnly); QCOMPARE(get("online/nonexistant"), PinState::OnlineOnly); // Inheriting checks, level 2 - QCOMPARE(get("local/unspec/unspec"), PinState::AlwaysLocal); - QCOMPARE(get("local/local/unspec"), PinState::AlwaysLocal); + QCOMPARE(get("local/inherit/inherit"), PinState::AlwaysLocal); + QCOMPARE(get("local/local/inherit"), PinState::AlwaysLocal); QCOMPARE(get("local/local/nonexistant"), PinState::AlwaysLocal); - QCOMPARE(get("local/online/unspec"), PinState::OnlineOnly); + QCOMPARE(get("local/online/inherit"), PinState::OnlineOnly); QCOMPARE(get("local/online/nonexistant"), PinState::OnlineOnly); - QCOMPARE(get("online/unspec/unspec"), PinState::OnlineOnly); - QCOMPARE(get("online/local/unspec"), PinState::AlwaysLocal); + QCOMPARE(get("online/inherit/inherit"), PinState::OnlineOnly); + QCOMPARE(get("online/local/inherit"), PinState::AlwaysLocal); QCOMPARE(get("online/local/nonexistant"), PinState::AlwaysLocal); - QCOMPARE(get("online/online/unspec"), PinState::OnlineOnly); + QCOMPARE(get("online/online/inherit"), PinState::OnlineOnly); QCOMPARE(get("online/online/nonexistant"), PinState::OnlineOnly); + + // Check changing the root pin state + make("", PinState::OnlineOnly); + QCOMPARE(get("local"), PinState::AlwaysLocal); + QCOMPARE(get("online"), PinState::OnlineOnly); + QCOMPARE(get("inherit"), PinState::OnlineOnly); + QCOMPARE(get("nonexistant"), PinState::OnlineOnly); + make("", PinState::AlwaysLocal); + QCOMPARE(get("local"), PinState::AlwaysLocal); + QCOMPARE(get("online"), PinState::OnlineOnly); + QCOMPARE(get("inherit"), PinState::AlwaysLocal); + QCOMPARE(get("nonexistant"), PinState::AlwaysLocal); } private: diff --git a/test/testsyncvirtualfiles.cpp b/test/testsyncvirtualfiles.cpp index cc38527a9..7c55eaaa0 100644 --- a/test/testsyncvirtualfiles.cpp +++ b/test/testsyncvirtualfiles.cpp @@ -59,11 +59,11 @@ void markForDehydration(FakeFolder &folder, const QByteArray &path) journal.avoidReadFromDbOnNextSync(record._path); } -SyncOptions vfsSyncOptions() +SyncOptions vfsSyncOptions(FakeFolder &fakeFolder) { SyncOptions options; options._vfs.reset(createVfsFromPlugin(Vfs::WithSuffix).release()); - options._newFilesAreVirtual = true; + fakeFolder.syncJournal().setPinStateForPath("", PinState::OnlineOnly); return options; } @@ -85,7 +85,7 @@ private slots: QFETCH(bool, doLocalDiscovery); FakeFolder fakeFolder{ FileInfo() }; - fakeFolder.syncEngine().setSyncOptions(vfsSyncOptions()); + fakeFolder.syncEngine().setSyncOptions(vfsSyncOptions(fakeFolder)); QCOMPARE(fakeFolder.currentLocalState(), fakeFolder.currentRemoteState()); QSignalSpy completeSpy(&fakeFolder.syncEngine(), SIGNAL(itemCompleted(const SyncFileItemPtr &))); @@ -206,7 +206,7 @@ private slots: void testVirtualFileConflict() { FakeFolder fakeFolder{ FileInfo() }; - fakeFolder.syncEngine().setSyncOptions(vfsSyncOptions()); + fakeFolder.syncEngine().setSyncOptions(vfsSyncOptions(fakeFolder)); QCOMPARE(fakeFolder.currentLocalState(), fakeFolder.currentRemoteState()); QSignalSpy completeSpy(&fakeFolder.syncEngine(), SIGNAL(itemCompleted(const SyncFileItemPtr &))); @@ -277,7 +277,7 @@ private slots: void testWithNormalSync() { FakeFolder fakeFolder{ FileInfo::A12_B12_C12_S12() }; - fakeFolder.syncEngine().setSyncOptions(vfsSyncOptions()); + fakeFolder.syncEngine().setSyncOptions(vfsSyncOptions(fakeFolder)); QCOMPARE(fakeFolder.currentLocalState(), fakeFolder.currentRemoteState()); QSignalSpy completeSpy(&fakeFolder.syncEngine(), SIGNAL(itemCompleted(const SyncFileItemPtr &))); @@ -313,7 +313,7 @@ private slots: void testVirtualFileDownload() { FakeFolder fakeFolder{ FileInfo() }; - fakeFolder.syncEngine().setSyncOptions(vfsSyncOptions()); + fakeFolder.syncEngine().setSyncOptions(vfsSyncOptions(fakeFolder)); QCOMPARE(fakeFolder.currentLocalState(), fakeFolder.currentRemoteState()); QSignalSpy completeSpy(&fakeFolder.syncEngine(), SIGNAL(itemCompleted(const SyncFileItemPtr &))); @@ -381,7 +381,7 @@ private slots: void testVirtualFileDownloadResume() { FakeFolder fakeFolder{ FileInfo() }; - fakeFolder.syncEngine().setSyncOptions(vfsSyncOptions()); + fakeFolder.syncEngine().setSyncOptions(vfsSyncOptions(fakeFolder)); QCOMPARE(fakeFolder.currentLocalState(), fakeFolder.currentRemoteState()); QSignalSpy completeSpy(&fakeFolder.syncEngine(), SIGNAL(itemCompleted(const SyncFileItemPtr &))); @@ -422,7 +422,7 @@ private slots: void testNewFilesNotVirtual() { FakeFolder fakeFolder{ FileInfo() }; - SyncOptions syncOptions = vfsSyncOptions(); + SyncOptions syncOptions = vfsSyncOptions(fakeFolder); fakeFolder.syncEngine().setSyncOptions(syncOptions); QCOMPARE(fakeFolder.currentLocalState(), fakeFolder.currentRemoteState()); @@ -431,8 +431,7 @@ private slots: QVERIFY(fakeFolder.syncOnce()); QVERIFY(fakeFolder.currentLocalState().find("A/a1.nextcloud")); - syncOptions._newFilesAreVirtual = false; - fakeFolder.syncEngine().setSyncOptions(syncOptions); + fakeFolder.syncJournal().setPinStateForPath("", PinState::AlwaysLocal); // Create a new remote file, it'll not be virtual fakeFolder.remoteModifier().insert("A/a2"); @@ -444,7 +443,7 @@ private slots: void testDownloadRecursive() { FakeFolder fakeFolder{ FileInfo() }; - fakeFolder.syncEngine().setSyncOptions(vfsSyncOptions()); + fakeFolder.syncEngine().setSyncOptions(vfsSyncOptions(fakeFolder)); QCOMPARE(fakeFolder.currentLocalState(), fakeFolder.currentRemoteState()); // Create a virtual file for remote files @@ -541,7 +540,7 @@ private slots: void testRenameToVirtual() { FakeFolder fakeFolder{ FileInfo::A12_B12_C12_S12() }; - fakeFolder.syncEngine().setSyncOptions(vfsSyncOptions()); + fakeFolder.syncEngine().setSyncOptions(vfsSyncOptions(fakeFolder)); QCOMPARE(fakeFolder.currentLocalState(), fakeFolder.currentRemoteState()); QSignalSpy completeSpy(&fakeFolder.syncEngine(), SIGNAL(itemCompleted(const SyncFileItemPtr &))); @@ -579,7 +578,7 @@ private slots: void testRenameVirtual() { FakeFolder fakeFolder{ FileInfo() }; - fakeFolder.syncEngine().setSyncOptions(vfsSyncOptions()); + fakeFolder.syncEngine().setSyncOptions(vfsSyncOptions(fakeFolder)); QCOMPARE(fakeFolder.currentLocalState(), fakeFolder.currentRemoteState()); QSignalSpy completeSpy(&fakeFolder.syncEngine(), SIGNAL(itemCompleted(const SyncFileItemPtr &))); @@ -621,7 +620,7 @@ private slots: void testSyncDehydration() { FakeFolder fakeFolder{ FileInfo::A12_B12_C12_S12() }; - fakeFolder.syncEngine().setSyncOptions(vfsSyncOptions()); + fakeFolder.syncEngine().setSyncOptions(vfsSyncOptions(fakeFolder)); QVERIFY(fakeFolder.syncOnce()); QCOMPARE(fakeFolder.currentLocalState(), fakeFolder.currentRemoteState()); @@ -698,7 +697,7 @@ private slots: void testWipeVirtualSuffixFiles() { FakeFolder fakeFolder{ FileInfo{} }; - fakeFolder.syncEngine().setSyncOptions(vfsSyncOptions()); + fakeFolder.syncEngine().setSyncOptions(vfsSyncOptions(fakeFolder)); // Create a suffix-vfs baseline @@ -743,8 +742,7 @@ private slots: void testNewVirtuals() { FakeFolder fakeFolder{ FileInfo() }; - SyncOptions syncOptions = vfsSyncOptions(); - syncOptions._newFilesAreVirtual = true; + SyncOptions syncOptions = vfsSyncOptions(fakeFolder); fakeFolder.syncEngine().setSyncOptions(syncOptions); QCOMPARE(fakeFolder.currentLocalState(), fakeFolder.currentRemoteState()); @@ -774,8 +772,7 @@ private slots: QVERIFY(fakeFolder.currentLocalState().find("unspec/file1.nextcloud")); // Test 2: root is AlwaysLocal - syncOptions._newFilesAreVirtual = false; - fakeFolder.syncEngine().setSyncOptions(syncOptions); + fakeFolder.syncJournal().setPinStateForPath("", PinState::AlwaysLocal); fakeFolder.remoteModifier().insert("file2"); fakeFolder.remoteModifier().insert("online/file2");