Replace WaitForFinishedInParentDirectory with WaitForFinished for directory moves
authorJocelyn Turcotte <jturcotte@woboq.com>
Mon, 13 Feb 2017 14:57:28 +0000 (15:57 +0100)
committerJocelyn Turcotte <jturcotte@woboq.com>
Thu, 23 Feb 2017 16:54:33 +0000 (17:54 +0100)
In preparation for the PropagateDirectory refactoring, simplify things
by removing WaitForFinishedInParentDirectory, which is currently
implemented as a one-level check.

This value is important for directory items, but is however never
used since a directory CSYNC_INSTRUCTION_RENAME item will always be in
PropagateDirectory::_firstJob, which will have to pass through its own
PropagateDirectory job's parallelism() before reaching the parent's
_subJobs optimization.
Since PropagateDirectory::parallelism can only return WaitForFinished
or FullParallelism, that value is lost. So this commit doesn't
change the behavior for directories, and allow file renames to be
scheduled in parallel across directories (which isn't a problem).

src/libsync/owncloudpropagator.cpp
src/libsync/owncloudpropagator.h
src/libsync/propagateremotemove.h
src/libsync/propagatorjobs.h

index f54d57a334d7782e5f6ed9a625cf22b5041dcde5..c7468bb0881c1154f151f6458e3b412930694406 100644 (file)
@@ -621,16 +621,11 @@ bool PropagateDirectory::scheduleNextJob()
         return false;
     }
 
-    bool stopAtDirectory = false;
     for (int i = 0; i < _subJobs.size(); ++i) {
         if (_subJobs.at(i)->_state == Finished) {
             continue;
         }
 
-        if (stopAtDirectory && qobject_cast<PropagateDirectory*>(_subJobs.at(i))) {
-            return false;
-        }
-
         if (possiblyRunNextJob(_subJobs.at(i))) {
             return true;
         }
@@ -641,9 +636,6 @@ bool PropagateDirectory::scheduleNextJob()
         if (paral == WaitForFinished) {
             return false;
         }
-        if (paral == WaitForFinishedInParentDirectory) {
-            stopAtDirectory = true;
-        }
     }
     return false;
 }
index 5a3763d4939890683f36d5a8a8abc62e2e5c7282..07328939cddcdc8c6bd0b541f96e63df9db4793a 100644 (file)
@@ -76,12 +76,6 @@ public:
             So this job is guaranteed to finish before any jobs below it
             are executed. */
         WaitForFinished,
-
-        /** A job with this parallelism will allow later jobs to start and
-            run in parallel as long as they aren't PropagateDirectory jobs.
-            When the first directory job is encountered, no further jobs
-            will be started until this one is finished. */
-        WaitForFinishedInParentDirectory
     };
 
     virtual JobParallelism parallelism() { return FullParallelism; }
index 8d213e43099a2557938e6d5ffbeaaf98bc896768..afda27b2f5014ff416ab4cf7405871a621d33ee3 100644 (file)
@@ -54,7 +54,7 @@ public:
         : PropagateItemJob(propagator, item) {}
     void start() Q_DECL_OVERRIDE;
     void abort() Q_DECL_OVERRIDE;
-    JobParallelism parallelism() Q_DECL_OVERRIDE { return OCC::PropagatorJob::WaitForFinishedInParentDirectory; }
+    JobParallelism parallelism() Q_DECL_OVERRIDE { return _item->_isDirectory ? WaitForFinished : FullParallelism; }
 
     /**
      * Rename the directory in the selective sync list
index c3898db48b96ff7029095fba01a1acfb06142c2b..88413d34e985c48a597518d2cb69dd95804a8550 100644 (file)
@@ -79,7 +79,7 @@ class PropagateLocalRename : public PropagateItemJob {
 public:
     PropagateLocalRename (OwncloudPropagator* propagator,const SyncFileItemPtr& item)  : PropagateItemJob(propagator, item) {}
     void start() Q_DECL_OVERRIDE;
-    JobParallelism parallelism() Q_DECL_OVERRIDE { return WaitForFinishedInParentDirectory; }
+    JobParallelism parallelism() Q_DECL_OVERRIDE { return _item->_isDirectory ? WaitForFinished : FullParallelism; }
 };
 
 }