From: Olivier Goffart Date: Mon, 15 Jan 2018 16:29:48 +0000 (+0100) Subject: Placeholders: Move the placeholder option from the account to the folder X-Git-Tag: archive/raspbian/3.16.7-1_deb13u1+rpi1~1^2~12^2~21^2~468^2~619 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=1049fb74d9093515ba4c1eb990d39fcf08ba0472;p=nextcloud-desktop.git Placeholders: Move the placeholder option from the account to the folder --- diff --git a/src/gui/folder.cpp b/src/gui/folder.cpp index 8cd997340..2ed886550 100644 --- a/src/gui/folder.cpp +++ b/src/gui/folder.cpp @@ -714,6 +714,7 @@ void Folder::setSyncOptions() opt._newBigFolderSizeLimit = newFolderLimit.first ? newFolderLimit.second * 1000LL * 1000LL : -1; // convert from MB to B opt._confirmExternalStorage = cfgFile.confirmExternalStorage(); opt._moveFilesToTrash = cfgFile.moveToTrash(); + opt._usePlaceholders = _definition.usePlaceholders; QByteArray chunkSizeEnv = qgetenv("OWNCLOUD_CHUNK_SIZE"); if (!chunkSizeEnv.isEmpty()) { @@ -1126,6 +1127,7 @@ void FolderDefinition::save(QSettings &settings, const FolderDefinition &folder) settings.setValue(QLatin1String("targetPath"), folder.targetPath); settings.setValue(QLatin1String("paused"), folder.paused); settings.setValue(QLatin1String("ignoreHiddenFiles"), folder.ignoreHiddenFiles); + settings.setValue(QLatin1String("usePlaceholders"), folder.usePlaceholders); // Happens only on Windows when the explorer integration is enabled. if (!folder.navigationPaneClsid.isNull()) @@ -1146,6 +1148,7 @@ 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->usePlaceholders = settings.value(QLatin1String("usePlaceholders")).toBool(); settings.endGroup(); // Old settings can contain paths with native separators. In the rest of the diff --git a/src/gui/folder.h b/src/gui/folder.h index 095a813d0..778e35ad5 100644 --- a/src/gui/folder.h +++ b/src/gui/folder.h @@ -59,6 +59,8 @@ public: bool paused = false; /// whether the folder syncs hidden files bool ignoreHiddenFiles = false; + /// New files are downloaded as placeholders + bool usePlaceholders = false; /// The CLSID where this folder appears in registry for the Explorer navigation pane entry. QUuid navigationPaneClsid; diff --git a/src/libsync/account.h b/src/libsync/account.h index 1f7d9608f..92008ff08 100644 --- a/src/libsync/account.h +++ b/src/libsync/account.h @@ -249,9 +249,6 @@ public: // Check for the directEditing capability void fetchDirectEditors(const QUrl &directEditingURL, const QString &directEditingETag); - bool usePlaceholders() const { return _usePlaceholders; } - void setUsePlaceholders(bool use) { _usePlaceholders = use; } - public slots: /// Used when forgetting credentials void clearQNAMCache(); @@ -348,8 +345,6 @@ private: private: bool _isRemoteWipeRequested_HACK = false; // <-- FIXME MS@2019-12-07 - - bool _usePlaceholders = false; }; } diff --git a/src/libsync/syncengine.cpp b/src/libsync/syncengine.cpp index 9bd03bc0c..69e7f7d25 100644 --- a/src/libsync/syncengine.cpp +++ b/src/libsync/syncengine.cpp @@ -858,7 +858,7 @@ void SyncEngine::startSync() return shouldDiscoverLocally(path); }; - _csync_ctx->new_files_are_placeholders = account()->usePlaceholders(); + _csync_ctx->new_files_are_placeholders = _syncOptions._usePlaceholders; // If needed, make sure we have up to date E2E information before the // discovery phase, otherwise we start right away diff --git a/src/libsync/syncoptions.h b/src/libsync/syncoptions.h index 676bfbeb7..e9e97efec 100644 --- a/src/libsync/syncoptions.h +++ b/src/libsync/syncoptions.h @@ -36,6 +36,9 @@ struct SyncOptions /** If remotely deleted files are needed to move to trash */ bool _moveFilesToTrash = false; + /** Create a placeholder for new files instead of downloading */ + bool _usePlaceholders = 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/testsyncplaceholders.cpp b/test/testsyncplaceholders.cpp index 7d94ee8a5..038da9a5c 100644 --- a/test/testsyncplaceholders.cpp +++ b/test/testsyncplaceholders.cpp @@ -52,7 +52,9 @@ private slots: QFETCH(bool, doLocalDiscovery); FakeFolder fakeFolder{FileInfo()}; - fakeFolder.syncEngine().account()->setUsePlaceholders(true); + SyncOptions syncOptions; + syncOptions._usePlaceholders = true; + fakeFolder.syncEngine().setSyncOptions(syncOptions); QCOMPARE(fakeFolder.currentLocalState(), fakeFolder.currentRemoteState()); QSignalSpy completeSpy(&fakeFolder.syncEngine(), SIGNAL(itemCompleted(const SyncFileItemPtr &))); @@ -132,7 +134,9 @@ private slots: void testWithNormalSync() { FakeFolder fakeFolder{FileInfo::A12_B12_C12_S12()}; - fakeFolder.syncEngine().account()->setUsePlaceholders(true); + SyncOptions syncOptions; + syncOptions._usePlaceholders = true; + fakeFolder.syncEngine().setSyncOptions(syncOptions); QCOMPARE(fakeFolder.currentLocalState(), fakeFolder.currentRemoteState()); QSignalSpy completeSpy(&fakeFolder.syncEngine(), SIGNAL(itemCompleted(const SyncFileItemPtr &))); @@ -168,7 +172,9 @@ private slots: void testPlaceholderDownload() { FakeFolder fakeFolder{FileInfo()}; - fakeFolder.syncEngine().account()->setUsePlaceholders(true); + SyncOptions syncOptions; + syncOptions._usePlaceholders = true; + fakeFolder.syncEngine().setSyncOptions(syncOptions); QCOMPARE(fakeFolder.currentLocalState(), fakeFolder.currentRemoteState()); QSignalSpy completeSpy(&fakeFolder.syncEngine(), SIGNAL(itemCompleted(const SyncFileItemPtr &)));