Skip to content

Commit

Permalink
do not skip folder deletion if BlacklistedError during propagation
Browse files Browse the repository at this point in the history
in case some propgation actions ends up with a BlacklistedError, we
would skip the deletions of local folders (even though they have been
deleted from server)

let's not skip them but rather keep track of the error status and
properly report them

Signed-off-by: Matthieu Gallien <matthieu.gallien@nextcloud.com>
  • Loading branch information
mgallien committed Nov 7, 2022
1 parent 783cefe commit 402d959
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 3 deletions.
34 changes: 33 additions & 1 deletion src/libsync/owncloudpropagator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -594,7 +594,7 @@ void OwncloudPropagator::start(SyncFileItemVector &&items)
}

foreach (PropagatorJob *it, directoriesToRemove) {
_rootJob->_dirDeletionJobs.appendJob(it);
_rootJob->appendDirDeletionJob(it);
}

connect(_rootJob.data(), &PropagatorJob::finished, this, &OwncloudPropagator::emitFinished);
Expand Down Expand Up @@ -1292,6 +1292,11 @@ qint64 PropagateRootDirectory::committedDiskSpace() const
return _subJobs.committedDiskSpace() + _dirDeletionJobs.committedDiskSpace();
}

void PropagateRootDirectory::appendDirDeletionJob(PropagatorJob *job)
{
_dirDeletionJobs.appendJob(job);
}

bool PropagateRootDirectory::scheduleSelfOrChild()
{
qCInfo(lcRootDirectory()) << "scheduleSelfOrChild" << _state << "pending uploads" << propagator()->delayedTasks().size() << "subjobs state" << _subJobs._state;
Expand Down Expand Up @@ -1327,6 +1332,7 @@ void PropagateRootDirectory::slotSubJobsFinished(SyncFileItem::Status status)

if (status != SyncFileItem::Success
&& status != SyncFileItem::Restoration
&& status != SyncFileItem::BlacklistedError
&& status != SyncFileItem::Conflict) {
if (_state != Finished) {
// Synchronously abort
Expand All @@ -1338,11 +1344,37 @@ void PropagateRootDirectory::slotSubJobsFinished(SyncFileItem::Status status)
return;
}

if (_errorStatus == SyncFileItem::NoStatus) {
switch (status) {
case SyncFileItem::NoStatus:
case SyncFileItem::FatalError:
case SyncFileItem::NormalError:
case SyncFileItem::SoftError:
case SyncFileItem::Conflict:
case SyncFileItem::FileIgnored:
case SyncFileItem::FileLocked:
case SyncFileItem::Restoration:
case SyncFileItem::FileNameInvalid:
case SyncFileItem::FileNameClash:
case SyncFileItem::DetailError:
case SyncFileItem::Success:
break;
case SyncFileItem::BlacklistedError:
_errorStatus = SyncFileItem::BlacklistedError;
break;
}
}

propagator()->scheduleNextJob();
}

void PropagateRootDirectory::slotDirDeletionJobsFinished(SyncFileItem::Status status)
{
if (_errorStatus != SyncFileItem::NoStatus && status == SyncFileItem::Success) {
qCInfo(lcPropagator) << "PropagateRootDirectory::slotDirDeletionJobsFinished" << "reporting previous error" << _errorStatus;
status = _errorStatus;
}

_state = Finished;
qCInfo(lcPropagator) << "PropagateRootDirectory::slotDirDeletionJobsFinished" << "emit finished" << status;
emit finished(status);
Expand Down
9 changes: 7 additions & 2 deletions src/libsync/owncloudpropagator.h
Original file line number Diff line number Diff line change
Expand Up @@ -365,8 +365,6 @@ class OWNCLOUDSYNC_EXPORT PropagateRootDirectory : public PropagateDirectory
{
Q_OBJECT
public:
PropagatorCompositeJob _dirDeletionJobs;

explicit PropagateRootDirectory(OwncloudPropagator *propagator);

bool scheduleSelfOrChild() override;
Expand All @@ -375,13 +373,20 @@ class OWNCLOUDSYNC_EXPORT PropagateRootDirectory : public PropagateDirectory

[[nodiscard]] qint64 committedDiskSpace() const override;

public slots:
void appendDirDeletionJob(PropagatorJob *job);

private slots:
void slotSubJobsFinished(SyncFileItem::Status status) override;
void slotDirDeletionJobsFinished(SyncFileItem::Status status);

private:

bool scheduleDelayedJobs();

PropagatorCompositeJob _dirDeletionJobs;

SyncFileItem::Status _errorStatus = SyncFileItem::Status::NoStatus;
};

/**
Expand Down

0 comments on commit 402d959

Please sign in to comment.