Skip to content

Commit

Permalink
Merge branch 'develop' into KDESKTOP-830-Implement-functions-to-gener…
Browse files Browse the repository at this point in the history
…ate-the-support-log-arrchive
  • Loading branch information
herve-er committed May 6, 2024
2 parents 7f7b77e + 7163c2e commit a6a53ec
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/libsyncengine/jobs/network/abstractnetworkjob.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -498,6 +498,7 @@ bool AbstractNetworkJob::followRedirect(std::istream &inputStream) {
bool receiveOk = receiveResponse(session, uri);
if (!receiveOk && _resHttp.getStatus() == Poco::Net::HTTPResponse::HTTP_NOT_FOUND) {
// Special cases where the file exist in DB but not in storage
_downloadImpossible = true;
return true;
}
return receiveOk;
Expand Down
4 changes: 4 additions & 0 deletions src/libsyncengine/jobs/network/abstractnetworkjob.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ class AbstractNetworkJob : public AbstractJob {
inline Poco::Net::HTTPResponse::HTTPStatus getStatusCode() const { return _resHttp.getStatus(); }
virtual void abort() override;

inline bool isDownloadImpossible() const { return _downloadImpossible; }

protected:
virtual void runJob() noexcept override;
virtual void addRawHeader(const std::string &key, const std::string &value) final;
Expand Down Expand Up @@ -116,6 +118,8 @@ class AbstractNetworkJob : public AbstractJob {
static bool isManagedError(ExitCode exitCode, ExitCause exitCause) noexcept;

std::unordered_map<std::string, std::string> _rawHeaders;

bool _downloadImpossible {false};
};

} // namespace KDC
14 changes: 11 additions & 3 deletions src/libsyncengine/propagation/executor/executorworker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1622,8 +1622,16 @@ bool ExecutorWorker::deleteFinishedAsyncJobs() {
return !hasError;
}

bool ExecutorWorker::handleManagedBackError(ExitCause jobExitCause, SyncOpPtr syncOp, bool isInconsistencyIssue) {
bool ExecutorWorker::handleManagedBackError(ExitCause jobExitCause, SyncOpPtr syncOp, bool isInconsistencyIssue, bool downloadImpossible) {
_executorExitCode = ExitCodeOk;

if (jobExitCause == ExitCauseNotFound && !downloadImpossible) {
// The operation failed because the destination does not exist anymore
_executorExitCode = ExitCodeDataError;
LOG_DEBUG(_logger, "Destination does not exist anymore, restarting sync.");
return false;
}

if (jobExitCause == ExitCauseQuotaExceeded) {
_syncPal->pause();
} else {
Expand Down Expand Up @@ -1693,13 +1701,13 @@ bool ExecutorWorker::handleFinishedJob(std::shared_ptr<AbstractJob> job, SyncOpP
if (syncOp->correspondingNode() && syncOp->correspondingNode()->id()) remoteNodeId = *syncOp->correspondingNode()->id();
}

auto networkJob(std::dynamic_pointer_cast<AbstractNetworkJob>(job));
if (const bool isInconsistencyIssue = job->exitCause() == ExitCauseInvalidName;
job->exitCode() == ExitCodeBackError && details::isManagedBackError(job->exitCause())) {
return handleManagedBackError(job->exitCause(), syncOp, isInconsistencyIssue);
return handleManagedBackError(job->exitCause(), syncOp, isInconsistencyIssue, networkJob->isDownloadImpossible());
}

if (job->exitCode() != ExitCodeOk) {
auto networkJob(std::dynamic_pointer_cast<AbstractNetworkJob>(job));
if (networkJob && (networkJob->getStatusCode() == Poco::Net::HTTPResponse::HTTP_FORBIDDEN ||
networkJob->getStatusCode() == Poco::Net::HTTPResponse::HTTP_CONFLICT)) {
handleForbiddenAction(syncOp, relativeLocalPath);
Expand Down
2 changes: 1 addition & 1 deletion src/libsyncengine/propagation/executor/executorworker.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class ExecutorWorker : public OperationProcessor {

void waitForAllJobsToFinish(bool &hasError);
bool deleteFinishedAsyncJobs();
bool handleManagedBackError(ExitCause jobExitCause, SyncOpPtr syncOp, bool isInconsistencyIssue);
bool handleManagedBackError(ExitCause jobExitCause, SyncOpPtr syncOp, bool isInconsistencyIssue, bool downloadImpossible);
bool handleFinishedJob(std::shared_ptr<AbstractJob> job, SyncOpPtr syncOp, const SyncPath &relativeLocalPath);
void handleForbiddenAction(SyncOpPtr syncOp, const SyncPath &relativeLocalPath);
void sendProgress();
Expand Down

0 comments on commit a6a53ec

Please sign in to comment.