浏览代码

Placeholders: Move the placeholder option from the account to the folder

Olivier Goffart 8 年之前
父节点
当前提交
1049fb74d9
共有 6 个文件被更改,包括 18 次插入9 次删除
  1. 3 0
      src/gui/folder.cpp
  2. 2 0
      src/gui/folder.h
  3. 0 5
      src/libsync/account.h
  4. 1 1
      src/libsync/syncengine.cpp
  5. 3 0
      src/libsync/syncoptions.h
  6. 9 3
      test/testsyncplaceholders.cpp

+ 3 - 0
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

+ 2 - 0
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;
 

+ 0 - 5
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;
 };
 }
 

+ 1 - 1
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

+ 3 - 0
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
      *

+ 9 - 3
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 &)));