Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/owncloud/client.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorKlaas Freitag <freitag@owncloud.com>2014-12-06 14:27:50 +0300
committerKlaas Freitag <freitag@owncloud.com>2014-12-06 14:31:45 +0300
commit1d6661e7e492a3a82b9f9b5a611ae882195a3904 (patch)
treeaccefc3b686cfabf22a3db1bc54061562cab6f36 /src
parenta43173fa9040d0463ade986a9a59bf8af4764969 (diff)
Fix the number of displayed items in progress display for removes.
This fixes mirall#1132 A variable that counts the affected items of the propagator operation done on a item was added to SyncFileItem. Usually that is 1 because most operations affect only the item itself. But for removes, the number can be higher for directories (one remove removes a whole tree). Some rearrangements were needed.
Diffstat (limited to 'src')
-rw-r--r--src/mirall/owncloudpropagator.cpp10
-rw-r--r--src/mirall/owncloudpropagator.h84
-rw-r--r--src/mirall/progressdispatcher.h12
-rw-r--r--src/mirall/syncengine.cpp4
-rw-r--r--src/mirall/syncfileitem.h8
5 files changed, 73 insertions, 45 deletions
diff --git a/src/mirall/owncloudpropagator.cpp b/src/mirall/owncloudpropagator.cpp
index 79dad9854..7fbac19bd 100644
--- a/src/mirall/owncloudpropagator.cpp
+++ b/src/mirall/owncloudpropagator.cpp
@@ -248,13 +248,23 @@ void OwncloudPropagator::start(const SyncFileItemVector& items)
if (!removedDirectory.isEmpty() && item._file.startsWith(removedDirectory)) {
// this is an item in a directory which is going to be removed.
+ PropagateDirectory *delDirJob = dynamic_cast<PropagateDirectory*>(directoriesToRemove.last());
+
if (item._instruction == CSYNC_INSTRUCTION_REMOVE) {
//already taken care of. (by the removal of the parent directory)
+
+ // increase the number of subjobs that would be there.
+ if( delDirJob ) {
+ delDirJob->increaseAffectedCount();
+ }
continue;
} else if (item._instruction == CSYNC_INSTRUCTION_NEW && item._isDirectory) {
// create a new directory within a deleted directory? That can happen if the directory
// etag were not fetched properly on the previous sync because the sync was aborted
// while uploading this directory (which is now removed). We can ignore it.
+ if( delDirJob ) {
+ delDirJob->increaseAffectedCount();
+ }
continue;
} else if (item._instruction == CSYNC_INSTRUCTION_IGNORE) {
continue;
diff --git a/src/mirall/owncloudpropagator.h b/src/mirall/owncloudpropagator.h
index b1e3fab27..3ebfc35e8 100644
--- a/src/mirall/owncloudpropagator.h
+++ b/src/mirall/owncloudpropagator.h
@@ -71,6 +71,43 @@ signals:
};
+
+/*
+ * Abstract class to propagate a single item
+ * (Only used for neon job)
+ */
+class PropagateItemJob : public PropagatorJob {
+ Q_OBJECT
+protected:
+ void done(SyncFileItem::Status status, const QString &errorString = QString());
+
+ bool checkForProblemsWithShared(int httpStatusCode, const QString& msg);
+
+ /*
+ * set a custom restore job message that is used if the restore job succeeded.
+ * It is displayed in the activity view.
+ */
+ QString restoreJobMsg() const {
+ return _item._isRestoration ? _item._errorString : QString();
+ }
+ void setRestoreJobMsg( const QString& msg = QString() ) {
+ _item._isRestoration = true;
+ _item._errorString = msg;
+ }
+
+protected slots:
+ void slotRestoreJobCompleted(const SyncFileItem& );
+
+private:
+ QScopedPointer<PropagateItemJob> _restoreJob;
+
+public:
+ PropagateItemJob(OwncloudPropagator* propagator, const SyncFileItem &item)
+ : PropagatorJob(propagator), _item(item) {}
+
+ SyncFileItem _item;
+};
+
/*
* Propagate a directory, and all its sub entries.
*/
@@ -78,7 +115,7 @@ class PropagateDirectory : public PropagatorJob {
Q_OBJECT
public:
// e.g: create the directory
- QScopedPointer<PropagatorJob>_firstJob;
+ QScopedPointer<PropagateItemJob>_firstJob;
// all the sub files or sub directories.
QVector<PropagatorJob *> _subJobs;
@@ -89,10 +126,10 @@ public:
int _runningNow; // number of subJob running now
SyncFileItem::Status _hasError; // NoStatus, or NormalError / SoftError if there was an error
-
explicit PropagateDirectory(OwncloudPropagator *propagator, const SyncFileItem &item = SyncFileItem())
: PropagatorJob(propagator)
- , _firstJob(0), _item(item), _current(-1), _runningNow(0), _hasError(SyncFileItem::NoStatus) { }
+ , _firstJob(0), _item(item), _current(-1), _runningNow(0), _hasError(SyncFileItem::NoStatus)
+ { }
virtual ~PropagateDirectory() {
qDeleteAll(_subJobs);
@@ -110,6 +147,10 @@ public:
j->abort();
}
+ void increaseAffectedCount() {
+ _firstJob->_item._affectedItems++;
+ }
+
private slots:
void startJob(PropagatorJob *next) {
connect(next, SIGNAL(finished(SyncFileItem::Status)), this, SLOT(slotSubJobFinished(SyncFileItem::Status)), Qt::QueuedConnection);
@@ -122,45 +163,10 @@ private slots:
void slotSubJobFinished(SyncFileItem::Status status);
void slotSubJobReady();
-};
-
-
-/*
- * Abstract class to propagate a single item
- * (Only used for neon job)
- */
-class PropagateItemJob : public PropagatorJob {
- Q_OBJECT
-protected:
- void done(SyncFileItem::Status status, const QString &errorString = QString());
-
- bool checkForProblemsWithShared(int httpStatusCode, const QString& msg);
- /*
- * set a custom restore job message that is used if the restore job succeeded.
- * It is displayed in the activity view.
- */
- QString restoreJobMsg() const {
- return _item._isRestoration ? _item._errorString : QString();
- }
- void setRestoreJobMsg( const QString& msg = QString() ) {
- _item._isRestoration = true;
- _item._errorString = msg;
- }
-
- SyncFileItem _item;
-
-protected slots:
- void slotRestoreJobCompleted(const SyncFileItem& );
+};
-private:
- QScopedPointer<PropagateItemJob> _restoreJob;
-public:
- PropagateItemJob(OwncloudPropagator* propagator, const SyncFileItem &item)
- : PropagatorJob(propagator), _item(item) {}
-
-};
// Dummy job that just mark it as completed and ignored.
class PropagateIgnoreJob : public PropagateItemJob {
diff --git a/src/mirall/progressdispatcher.h b/src/mirall/progressdispatcher.h
index 66a8e411f..940c4921c 100644
--- a/src/mirall/progressdispatcher.h
+++ b/src/mirall/progressdispatcher.h
@@ -20,6 +20,8 @@
#include <QTime>
#include <QQueue>
#include <QElapsedTimer>
+#include <QDebug>
+
#include "syncfileitem.h"
namespace Mirall {
@@ -112,11 +114,13 @@ namespace Progress
void setProgressComplete(const SyncFileItem &item) {
_currentItems.remove(item._file);
+ _completedFileCount += item._affectedItems;
if (!item._isDirectory) {
- _completedFileCount++;
- if (Progress::isSizeDependent(item._instruction)) {
- _completedSize += item._size;
- }
+ if (Progress::isSizeDependent(item._instruction)) {
+ _completedSize += item._size;
+ }
+ } else {
+ qDebug() << "Also reached for directories!";
}
_lastCompletedItem = item;
this->updateEstimation();
diff --git a/src/mirall/syncengine.cpp b/src/mirall/syncengine.cpp
index 373c7867e..36be6f8ed 100644
--- a/src/mirall/syncengine.cpp
+++ b/src/mirall/syncengine.cpp
@@ -380,7 +380,11 @@ int SyncEngine::treewalkFile( TREE_WALK_FILE *file, bool remote )
Q_ASSERT("Non handled error-status");
/* No error string */
}
+
item._isDirectory = file->type == CSYNC_FTW_TYPE_DIR;
+ if(item._isDirectory) {
+ item._affectedItems = 0; // defaults to 1 for normal items.
+ }
// The etag is already set in the previous sync phases somewhere. Maybe we should remove it there
// and do it here so we have a consistent state about which tree stores information from which source.
diff --git a/src/mirall/syncfileitem.h b/src/mirall/syncfileitem.h
index 22a758159..1ddf843d8 100644
--- a/src/mirall/syncfileitem.h
+++ b/src/mirall/syncfileitem.h
@@ -53,7 +53,10 @@ public:
SyncFileItem() : _type(UnknownType), _direction(None), _isDirectory(false),
_instruction(CSYNC_INSTRUCTION_NONE), _modtime(0),
_size(0), _inode(0), _should_update_etag(false), _hasBlacklistEntry(false),
- _status(NoStatus), _httpErrorCode(0), _requestDuration(0), _isRestoration(false) {}
+ _status(NoStatus), _httpErrorCode(0), _requestDuration(0), _isRestoration(false),
+ _affectedItems(1)
+ {
+ }
friend bool operator==(const SyncFileItem& item1, const SyncFileItem& item2) {
return item1._file == item2._file;
@@ -111,7 +114,8 @@ public:
QString _responseTimeStamp;
quint64 _requestDuration;
bool _isRestoration; // The original operation was forbidden, and this is a restoration
-
+ int _affectedItems; // the number of affected items by the operation on this item.
+ // usually this value is 1, but for removes on dirs, it might be much higher.
struct {
quint64 _size;
time_t _modtime;