Add sync option for nextcloudcmd.
authorCamila Ayres <hello@camilasan.com>
Tue, 25 Jun 2024 18:39:09 +0000 (20:39 +0200)
committerMatthieu Gallien <matthieu_gallien@yahoo.fr>
Fri, 28 Jun 2024 16:33:39 +0000 (18:33 +0200)
Signed-off-by: Camila Ayres <hello@camilasan.com>
src/cmd/cmd.cpp
src/libsync/syncengine.cpp
src/libsync/syncoptions.cpp
src/libsync/syncoptions.h

index 2a1be09c701ceb1eb614d5eaab5822e1545c3004..3c940ee2e9adcdfab42b37e2fecffde85e0a9917 100644 (file)
@@ -532,6 +532,7 @@ restart_sync:
     SyncOptions syncOptions;
     syncOptions.fillFromEnvironmentVariables();
     syncOptions.verifyChunkSizes();
+    syncOptions.setIsCmd(true);
     SyncEngine engine(account, options.source_dir, syncOptions, folder, &db);
     engine.setIgnoreHiddenFiles(options.ignoreHiddenFiles);
     engine.setNetworkLimits(options.uplimit, options.downlimit);
index 2ce9966d889b4e7bf94daaf7a0ecfa800ec9fcc1..3470504e2709fb1d0790abca889ccdcc61589d75 100644 (file)
@@ -898,7 +898,8 @@ void SyncEngine::slotDiscoveryFinished()
         qCInfo(lcEngine) << "#### Post-Reconcile end #################################################### " << _stopWatch.addLapTime(QStringLiteral("Post-Reconcile Finished")) << "ms";
     };
 
-    if (!_hasNoneFiles && _hasRemoveFile && ConfigFile().promptDeleteFiles()) {
+    const auto displayDialog = ConfigFile().promptDeleteFiles() && !_syncOptions.isCmd();
+    if (!_hasNoneFiles && _hasRemoveFile && displayDialog) {
         qCInfo(lcEngine) << "All the files are going to be changed, asking the user";
         int side = 0; // > 0 means more deleted on the server.  < 0 means more deleted on the client
         for (const auto &it : _syncItems) {
index c11d3a9bba2b157c5e505126ccb10d83bdbcd128..1585317a859eae6106a9daa5a7f0c23a24dc4942 100644 (file)
@@ -21,6 +21,7 @@ using namespace OCC;
 
 SyncOptions::SyncOptions()
     : _vfs(new VfsOff)
+    , _isCmd(false)
 {
 }
 
@@ -91,3 +92,13 @@ void SyncOptions::setPathPattern(const QString &pattern)
     _fileRegex.setPatternOptions(Utility::fsCasePreserving() ? QRegularExpression::CaseInsensitiveOption : QRegularExpression::NoPatternOption);
     _fileRegex.setPattern(pattern);
 }
+
+void SyncOptions::setIsCmd(const bool isCmd)
+{
+    _isCmd = isCmd;
+}
+
+bool SyncOptions::isCmd() const
+{
+    return _isCmd;
+}
index 092ac6fb6f1c630434f170267de3903c2d31ffd9..91ebf4f01531ecbe4586607fc27683c3dd959e10 100644 (file)
@@ -93,7 +93,6 @@ public:
      */
     void verifyChunkSizes();
 
-
     /** A regular expression to match file names
      * If no pattern is provided the default is an invalid regular expression.
      */
@@ -109,6 +108,10 @@ public:
      */
     void setPathPattern(const QString &pattern);
 
+    /** sync had been started via nextcloudcmd command line   */
+    [[nodiscard]] bool isCmd() const;
+    void setIsCmd(const bool isCmd);
+
 private:
     /**
      * Only sync files that match the expression
@@ -118,6 +121,8 @@ private:
 
     qint64 _minChunkSize = chunkV2MinChunkSize;
     qint64 _maxChunkSize = chunkV2MaxChunkSize;
+
+    bool _isCmd = false;
 };
 
 }